Skip to content

Instantly share code, notes, and snippets.

@bjacob
Created January 28, 2021 02:40
Show Gist options
  • Save bjacob/705aa7d4373ac365657bef02fbe726e0 to your computer and use it in GitHub Desktop.
Save bjacob/705aa7d4373ac365657bef02fbe726e0 to your computer and use it in GitHub Desktop.

So with this:

  LogicalResult matchAndRewrite(linalg::MatmulOp op,
                                PatternRewriter &rewriter) const override {
    rewriter.replaceOpWithNewOp<meh::MatmulOp>(op, op.getOperand(0),
                                               op.getOperand(1));
    return success();
  }

I get this build error:

/usr/local/google/home/benoitjacob/iree/third_party/llvm-project/mlir/include/mlir/IR/Builders.h:400:11: error: no matching member function for call to 'build'
    OpTy::build(*this, state, std::forward<Args>(args)...);
    ~~~~~~^~~~~
/usr/local/google/home/benoitjacob/iree/third_party/llvm-project/mlir/include/mlir/IR/PatternMatch.h:484:18: note: in instantiation of function template specialization 'mlir::OpBuilder::create<mlir::iree_compiler::meh::MatmulOp, mlir::Value, mlir::Value>' requested here
    auto newOp = create<OpTy>(op->getLoc(), std::forward<Args>(args)...);
                 ^
/usr/local/google/home/benoitjacob/iree/iree/compiler/Dialect/Meh/Conversion/LinalgToMeh/ConvertLinalgToMeh.cpp:39:14: note: in instantiation of function template specialization 'mlir::PatternRewriter::replaceOpWithNewOp<mlir::iree_compiler::meh::MatmulOp, mlir::Value, mlir::Value>' requested here
    rewriter.replaceOpWithNewOp<meh::MatmulOp>(op, op.getOperand(0),
             ^
./iree/compiler/Dialect/Meh/IR/MehOps.h.inc:62:15: note: candidate function not viable: no known conversion from 'mlir::Value' to '::mlir::TypeRange' for 3rd argument
  static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
              ^
./iree/compiler/Dialect/Meh/IR/MehOps.h.inc:60:15: note: candidate function not viable: requires 5 arguments, but 4 were provided
  static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value lhs, ::mlir::Value rhs);
              ^
./iree/compiler/Dialect/Meh/IR/MehOps.h.inc:61:15: note: candidate function not viable: requires 5 arguments, but 4 were provided
  static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs);

Here is my .td:

def Meh_MatmulOp : Meh_OP<"matmul", [
  ]> {
  let arguments = (ins 
    AnyTensor:$lhs, 
    AnyTensor:$rhs
  );
  let results = (outs
    AnyTensor:$dst
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment