-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulse python bindings enablement for QE Compiler Dialects
- Loading branch information
Showing
49 changed files
with
2,223 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//===- OQ3.h - OQ3 Dialect for C --------------------------------*- C++ -*-===// | ||
// | ||
// (C) Copyright IBM 2024. | ||
// | ||
// This code is part of Qiskit. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0 with LLVM | ||
// Exceptions. You may obtain a copy of this license in the LICENSE.txt | ||
// file in the root directory of this source tree. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// This file declares the c interface for the OQ3 dialect | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef C_DIALECT_OQ3_H | ||
#define C_DIALECT_OQ3_H | ||
|
||
#include "mlir-c/IR.h" | ||
#include "mlir-c/Support.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(OQ3, oq3); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // C_DIALECT_OQ3_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//===- Pulse.h - Pulse Dialect for C ----------------------------*- C++ -*-===// | ||
// | ||
// (C) Copyright IBM 2024. | ||
// | ||
// This code is part of Qiskit. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0 with LLVM | ||
// Exceptions. You may obtain a copy of this license in the LICENSE.txt | ||
// file in the root directory of this source tree. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// This file declares the c interface for the Pulse dialect | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef C_DIALECT_PULSE_H | ||
#define C_DIALECT_PULSE_H | ||
|
||
#include "mlir-c/IR.h" | ||
#include "mlir-c/Support.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(PULSE, pulse); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// CaptureType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool pulseTypeIsACaptureType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType pulseCaptureTypeGet(MlirContext ctx); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// FrameType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool pulseTypeIsAFrameType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType pulseFrameTypeGet(MlirContext ctx); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// KernelType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool pulseTypeIsAKernelType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType pulseKernelTypeGet(MlirContext ctx); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// MixedFrameType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool pulseTypeIsAMixedFrameType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType pulseMixedFrameTypeGet(MlirContext ctx); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// PortType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool pulseTypeIsAPortType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType pulsePortTypeGet(MlirContext ctx); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// WaveformType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool pulseTypeIsAWaveformType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType pulseWaveformTypeGet(MlirContext ctx); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // C_DIALECT_PULSE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//===- QCS.h - QCS Dialect for C --------------------------------*- C++ -*-===// | ||
// | ||
// (C) Copyright IBM 2024. | ||
// | ||
// This code is part of Qiskit. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0 with LLVM | ||
// Exceptions. You may obtain a copy of this license in the LICENSE.txt | ||
// file in the root directory of this source tree. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// This file declares the c interface for the QCS dialect | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef C_DIALECT_QCS_H | ||
#define C_DIALECT_QCS_H | ||
|
||
#include "mlir-c/IR.h" | ||
#include "mlir-c/Support.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(QCS, qcs); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // C_DIALECT_QCS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//===- QUIR.h - QUIR Dialect for C ------------------------------*- C++ -*-===// | ||
// | ||
// (C) Copyright IBM 2024. | ||
// | ||
// This code is part of Qiskit. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0 with LLVM | ||
// Exceptions. You may obtain a copy of this license in the LICENSE.txt | ||
// file in the root directory of this source tree. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// This file declares the c interface for the QUIR dialect | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef C_DIALECT_QUIR_H | ||
#define C_DIALECT_QUIR_H | ||
|
||
#include "mlir-c/IR.h" | ||
#include "mlir-c/Support.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(QUIR, quir); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// AngleType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool quirTypeIsAAngleType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType quirAngleTypeGet(MlirContext ctx, unsigned width); | ||
|
||
//===---------------------------------------------------------------------===// | ||
// DurationType | ||
//===---------------------------------------------------------------------===// | ||
|
||
MLIR_CAPI_EXPORTED bool quirTypeIsADurationType(MlirType type); | ||
|
||
MLIR_CAPI_EXPORTED MlirType quirDurationTypeGet(MlirContext ctx); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // C_DIALECT_QUIR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//===- DialectOQ3.cpp - OQ3 Dialect python bindings -------------*- C++ -*-===// | ||
// | ||
// (C) Copyright IBM 2024. | ||
// | ||
// This code is part of Qiskit. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0 with LLVM | ||
// Exceptions. You may obtain a copy of this license in the LICENSE.txt | ||
// file in the root directory of this source tree. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// This file implements the python bindings for the OQ3 dialect | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "qss-c/Dialect/OQ3.h" | ||
|
||
#include "mlir-c/IR.h" | ||
// NOLINTNEXTLINE(misc-include-cleaner) | ||
#include "mlir/Bindings/Python/PybindAdaptors.h" | ||
|
||
#include "pybind11/cast.h" | ||
#include "pybind11/detail/common.h" | ||
#include "pybind11/pybind11.h" | ||
#include "pybind11/pytypes.h" | ||
|
||
namespace py = pybind11; | ||
using namespace llvm; | ||
using namespace mlir; | ||
using namespace mlir::python; | ||
using namespace mlir::python::adaptors; | ||
|
||
// Intentionally left blank placeholder and for a common pattern across dialects | ||
void populateDialectOQ3Submodule(const pybind11::module &m) {} | ||
|
||
PYBIND11_MODULE(_qeDialectsOQ3, m) { | ||
m.doc() = "IBM Quantum OQ3 dialect."; | ||
populateDialectOQ3Submodule(m); | ||
|
||
//===--------------------------------------------------------------------===// | ||
// OQ3 dialect | ||
//===--------------------------------------------------------------------===// | ||
auto quir_m = m.def_submodule("oq3"); | ||
|
||
quir_m.def( | ||
"register_dialect", | ||
[](MlirContext context, bool load) { | ||
const MlirDialectHandle handle = mlirGetDialectHandle__oq3__(); | ||
mlirDialectHandleRegisterDialect(handle, context); | ||
if (load) | ||
mlirDialectHandleLoadDialect(handle, context); | ||
}, | ||
py::arg("context") = py::none(), py::arg("load") = true); | ||
} |
Oops, something went wrong.