[Mlir-commits] [llvm] [mlir] [TOSA] Add Tosa_Shape type and ConstShapeOp (PR #122547)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Mar 20 09:26:41 PDT 2025
Jerry-Ge wrote:
> Is there a helper to create `ConstShapeOp `or `Tosa_Shape `types in C++? I'm updating some patterns for tosa.tile and having to write something like the following snippet is quite wordyIMO:
>
> ```
> auto constantShapeOp = rewriter.create<ConstShapeOp>(
> getLoc(),
> shapeType::get(getContext(), rank),
> DenseIntElementsAttr::get(
> RankedTensorType::get({rank}, rewriter.getIndexType()),
> multiplies));
> ```
Thanks for the comment! I feel it's okay with only three arguments. See a more clear example here: https://github.com/llvm/llvm-project/blob/2df51fd9c491ef1ad90fbad5ce18ea8ff8bd3117/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp#L167.
If you feel it's too wordy to write everything in a single line, maybe just try declare the `shapeType` and `DenseIntElementsAttr` outside of the rewriter function?
https://github.com/llvm/llvm-project/pull/122547
More information about the Mlir-commits
mailing list