Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/Conversion/ArithToNeura/ArithToNeuraPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ using namespace mlir::neura;

namespace{

struct ArithFMulToNeuraFMul : public OpRewritePattern<mlir::arith::MulFOp> {
Comment thread
tancheng marked this conversation as resolved.
using OpRewritePattern::OpRewritePattern;

LogicalResult matchAndRewrite(arith::MulFOp op,
PatternRewriter &rewriter) const override {
Value lhs = op.getLhs();
Value rhs = op.getRhs();
Type resultType = op.getType();

rewriter.replaceOpWithNewOp<neura::FMulOp>(op, resultType, lhs, rhs, Value());
return success();
}
};

struct LowerArithToNeuraPass
: public PassWrapper<LowerArithToNeuraPass, OperationPass<func::FuncOp>> {

Expand All @@ -44,6 +58,7 @@ struct LowerArithToNeuraPass

void runOnOperation() override {
RewritePatternSet patterns(&getContext());
patterns.add<ArithFMulToNeuraFMul>(&getContext());
mlir::neura::arith2neura::populateWithGenerated(patterns);
if (failed(applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)))) {
signalPassFailure();
Expand Down