Fold arith.extract_slice into arith.constant when the source is a constant
splat and the result type is statically shaped.
Details
- Reviewers
mravishankar rriddle mehdi_amini
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
1254 | The ArrayRef<Attribute> argument to the folder is providing you with the constant inputs, you're not supposed to match it. |
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
1246 | Can you just pass in splat here instead of converting back to a generic attribute? There is overhead associated to this. |
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
1246 | Passing 'splat' causes an assertion in the get function because it expects an attribute of the element type, not a tensor type. Adding reshape sounds good to me. I will take a look. Thank you! |
There is already reshape(), but it didn't support a shape with a different number of element even for a splat type.
I relaxed the assert condition to allow a type with a different number of elements.
mlir/include/mlir/IR/BuiltinAttributes.h | ||
---|---|---|
655 ↗ | (On Diff #409456) | I think its clearer to keep reshape semantics to preserving the number of elements. Thats the general use of reshape through out MLIR. |
Introduce resizeSplat instead of using reshape since reshape is not suppposed
to change the number of elements.
mlir/include/mlir/IR/BuiltinAttributes.h | ||
---|---|---|
655 ↗ | (On Diff #409456) | I introduced resizeSplat to create a new attribute instead of reshape. |
Can you just pass in splat here instead of converting back to a generic attribute? There is overhead associated to this.
Otherwise we should add a method to be able to do: return splat.reshape(newShape);