Hi, as I am new to MLIR, I am trying to create a new dialect inside toy example. My aim is to convert toy dialect to my custom dialect. Using emit=mlir
I got,
module {
toy.func @main() {
%0 = toy.constant dense<[[2.000000e+00, 5.000000e+00, 7.000000e+00, 1.000000e+00, 5.000000e+00, 8.000000e+00]]> : tensor<1x6xf64>
toy.print %0 : tensor<1x6xf64>
toy.return
}
}
But what I want after transformation it will look like
module {
func.func @main() {
%0 = poseidon.constant dense<[[2.000000e+00, 5.000000e+00, 7.000000e+00, 1.000000e+00, 5.000000e+00, 8.000000e+00]]> : tensor<1x6xf64>
toy.print %0 : tensor<1x6xf64>
return
}
}
I am modifying toy example Ch7. My codebase tree is
Ch7
βββ CMakeLists.txt
βββ demo.toy
βββ include
β βββ CMakeLists.txt
β βββ Poseidon
β β βββ CMakeLists.txt
β β βββ Passes.h
β β βββ PoseidonDialect.h
β β βββ PoseidonDialect.td
β β βββ PoseidonOps.h
β β βββ PoseidonOps.td
β βββ toy
β βββ AST.h
β βββ CMakeLists.txt
β βββ Dialect.h
β βββ Lexer.h
β βββ MLIRGen.h
β βββ Ops.td
β βββ Parser.h
β βββ Passes.h
β βββ ShapeInferenceInterface.h
β βββ ShapeInferenceInterface.td
βββ mlir
β βββ Dialect.cpp
β βββ LowerToAffineLoops.cpp
β βββ LowerToLLVM.cpp
β βββ LowerToPoseidon.cpp
β βββ MLIRGen.cpp
β βββ PoseidonDialect.cpp
β βββ PoseidonOps.cpp
β βββ ShapeInferencePass.cpp
β βββ ToyCombine.cpp
β βββ ToyCombine.td
βββ parser
β βββ AST.cpp
βββ toyc.cpp
Based on LowerToAffineLoops.cpp
I have created LowerToPoseidon.cpp
only for ConstantOp, ReturnOP & FuncOp, But I am getting error when building:
In file included from /home/Projects/llvm-project/mlir/examples/toy/Ch7/mlir/LowerToPoseidon.cpp:16:
In file included from /home/Projects/llvm-project/mlir/examples/toy/Ch7/include/toy/Dialect.h:19:
In file included from /home/Projects/llvm-project/mlir/include/mlir/IR/FunctionInterfaces.h:17:
/home/Projects/llvm-project/mlir/include/mlir/IR/Builders.h:462:11: error: no matching member function for call to 'build'
OpTy::build(*this, state, std::forward<Args>(args)...);
~~~~~~^~~~~
/home/Projects/llvm-project/mlir/include/mlir/IR/PatternMatch.h:452:18: note: in instantiation of function template specialization 'mlir::OpBuilder::create<mlir::poseidon::Constantop>' requested here
auto newOp = create<OpTy>(op->getLoc(), std::forward<Args>(args)...);
^
/home/Projects/llvm-project/mlir/examples/toy/Ch7/mlir/LowerToPoseidon.cpp:97:18: note: in instantiation of function template specialization 'mlir::RewriterBase::replaceOpWithNewOp<mlir::poseidon::Constantop>' requested here
rewriter.replaceOpWithNewOp<poseidon::Constantop>(op);
^
/home/Projects/llvm-project/build/tools/mlir/examples/toy/Ch7/include/Poseidon/PoseidonOps.h.inc:111:15: note: candidate function not viable: requires 3 arguments, but 2 were provided
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, DenseElementsAttr value);
^
/home/Projects/llvm-project/build/tools/mlir/examples/toy/Ch7/include/Poseidon/PoseidonOps.h.inc:112:15: note: candidate function not viable: requires 3 arguments, but 2 were provided
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, double value);
^
/home/Projects/llvm-project/build/tools/mlir/examples/toy/Ch7/include/Poseidon/PoseidonOps.h.inc:113:15: note: candidate function not viable: requires 4 arguments, but 2 were provided
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::DenseElementsAttr value);
^
/home/Projects/llvm-project/build/tools/mlir/examples/toy/Ch7/include/Poseidon/PoseidonOps.h.inc:114:15: note: candidate function not viable: requires 4 arguments, but 2 were provided
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::DenseElementsAttr value);
^
/home/Projects/llvm-project/build/tools/mlir/examples/toy/Ch7/include/Poseidon/PoseidonOps.h.inc:115:15: note: candidate function not viable: requires at least 4 arguments, but 2 were provided
static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
^
1 error generated.
ninja: build stopped: subcommand failed.
Please help me out. Thanks!