Hi Folks:
I am bit confused on syntax/semantics of op builders
and any help on this is appreciated.
So, if i have an op defined as
def ConstOp : MyDialect<"constant", [ConstantLike]> {
let results = (outs MyDialect_MemrefType);
let arguments = (in ElementsAttr:$value);
// This part is probably not right totally.
let builder = [ OpBuilder<(ins "DenseElementsAttr":$value), [{
build($_builder, $_state, ?Type?, value); }]>
];
};
Then as I understand I can invoke the builder to construct ConstOp op as something like -
const void *val ; /// points to all the initial values for dataAttribute
std::vector<std::int64_t> dims = {4}; // just for example
mlirType = builder.getF32Type(); //just for example
mlir::RankedTensorType rankedType =
mlir::RankedTensorType::get(dims, mlirType);
auto dataAttribute = mlir::DenseElementsAttr::get(rankedType, val);
builder.create<MyDialect::ConstOp>(builder.getUnknownLoc(), returnType, dataAttribute)
My question - i am not following what the correspondence is between what builder.create<..>
sends and what OpBuilder build
expects ? Is there a cleaner better way for me to do this and construct ConstOp correctly?
Thanks a lot
Javed