Skip to content

Commit f7e73a1

Browse files
committed
add hasCompileTimeKnownUnitaryMatrix
1 parent bd7b2b1 commit f7e73a1

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

mlir/include/mlir/Dialect/QCO/IR/QCOOps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ def PowOp
12741274
OperandRange getParameters() { return getBodyUnitary().getParameters(); }
12751275
double getExponentValue();
12761276
[[nodiscard]] static StringRef getBaseSymbol() { return "pow"; }
1277+
[[nodiscard]] bool hasCompileTimeKnownUnitaryMatrix();
12771278
[[nodiscard]] std::optional<DynamicMatrix> getUnitaryMatrix();
12781279
}];
12791280

mlir/lib/Dialect/QCO/IR/Modifiers/PowOp.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,13 @@ void PowOp::getCanonicalizationPatterns(RewritePatternSet& results,
689689
MoveCtrlOutside, NegPowToInvPow>(context);
690690
}
691691

692+
bool PowOp::hasCompileTimeKnownUnitaryMatrix() {
693+
return all_of(getBody()->getOps<UnitaryOpInterface>(),
694+
[](UnitaryOpInterface op) {
695+
return op.hasCompileTimeKnownUnitaryMatrix();
696+
});
697+
}
698+
692699
std::optional<DynamicMatrix> PowOp::getUnitaryMatrix() {
693700
auto bodyUnitary = utils::getSoleBodyUnitary<UnitaryOpInterface>(*getBody());
694701
if (!bodyUnitary) {

0 commit comments

Comments
 (0)