Skip to content

Commit

Permalink
Add missing pass class definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pearu committed Dec 17, 2024
1 parent 3004928 commit a56b4ed
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions stablehlo/transforms/StablehloComplexMathExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,43 @@ static Value getConstantLikeSmallestNormalizedValue(OpBuilder &b, Location loc,
val);
}

//===----------------------------------------------------------------------===//
// Pass
//===----------------------------------------------------------------------===//

struct StablehloComplexMathExpanderPass
: public impl::StablehloComplexMathExpanderPassBase<
StablehloComplexMathExpanderPass> {
StablehloComplexMathExpanderPass()
: StablehloComplexMathExpanderPassBase<
StablehloComplexMathExpanderPass>() {}
public:
LogicalResult initialize(MLIRContext *context) override {
// auto targetVersion = validateTargetVersion(targetVersionOption);

config.useTopDownTraversal = true;
RewritePatternSet patterns_(context);
populateStablehloComplexMathExpanderPatterns(&patterns_, context/*,
targetVersion*/);
patterns = std::move(patterns_);
return success();
}

void runOnOperation() override {
auto func = getOperation();
if (failed(applyPatternsAndFoldGreedily(func, patterns, config))) {
func.emitError(
"Failed to converge StableHLOComplexMathExpanderPass in ")
<< config.maxIterations << " iterations";
signalPassFailure();
}
}

private:
FrozenRewritePatternSet patterns;
GreedyRewriteConfig config;
};

#include "stablehlo/transforms/StablehloComplexMathExpanderPatterns.h.inc"

} // namespace
Expand Down

0 comments on commit a56b4ed

Please sign in to comment.