-
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.
Merge branch 'main' into relkabetz/issue-2223-qe
- Loading branch information
Showing
124 changed files
with
4,105 additions
and
282 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
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,73 @@ | ||
//===- ExtractCircuits.h - Extract circuits ops -----------------*- 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 pass for extracting quantum ops into quir.circuits | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef QUIR_EXTRACT_CIRCUITS_H | ||
#define QUIR_EXTRACT_CIRCUITS_H | ||
|
||
#include "Dialect/QUIR/IR/QUIROps.h" | ||
|
||
#include "mlir/IR/BuiltinAttributes.h" | ||
#include "mlir/IR/PatternMatch.h" | ||
#include "mlir/Pass/Pass.h" | ||
|
||
#include "llvm/ADT/SmallVector.h" | ||
|
||
#include <unordered_map> | ||
|
||
namespace mlir::quir { | ||
|
||
struct ExtractCircuitsPass | ||
: public PassWrapper<ExtractCircuitsPass, OperationPass<>> { | ||
void runOnOperation() override; | ||
|
||
llvm::StringRef getArgument() const override; | ||
llvm::StringRef getDescription() const override; | ||
llvm::StringRef getName() const override; | ||
|
||
private: | ||
void processRegion(mlir::Region ®ion, OpBuilder topLevelBuilder, | ||
OpBuilder circuitBuilder); | ||
void processBlock(mlir::Block &block, OpBuilder topLevelBuilder, | ||
OpBuilder circuitBuilder); | ||
OpBuilder startCircuit(mlir::Location location, OpBuilder topLevelBuilder); | ||
void endCircuit(mlir::Operation *firstOp, mlir::Operation *lastOp, | ||
OpBuilder topLevelBuilder, OpBuilder circuitBuilder, | ||
llvm::SmallVector<Operation *> &eraseList); | ||
void addToCircuit(mlir::Operation *currentOp, OpBuilder circuitBuilder, | ||
llvm::SmallVector<Operation *> &eraseList); | ||
uint64_t circuitCount = 0; | ||
llvm::StringMap<Operation *> circuitOpsMap; | ||
|
||
mlir::quir::CircuitOp currentCircuitOp = nullptr; | ||
mlir::quir::CallCircuitOp newCallCircuitOp; | ||
|
||
llvm::SmallVector<Type> inputTypes; | ||
llvm::SmallVector<Value> inputValues; | ||
llvm::SmallVector<Type> outputTypes; | ||
llvm::SmallVector<Value> outputValues; | ||
std::vector<int> phyiscalIds; | ||
std::unordered_map<uint32_t, int> argToId; | ||
|
||
std::unordered_map<Operation *, uint32_t> circuitOperands; | ||
llvm::SmallVector<OpResult> originalResults; | ||
|
||
}; // struct ExtractCircuitsPass | ||
} // namespace mlir::quir | ||
#endif // QUIR_EXTRACT_CIRCUITS_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
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
Oops, something went wrong.