If any input to shape.any is a const_shape, shape.any can be replaced
with that input.
Details
- Reviewers
jpienaar silvas herhut - Commits
- rG4a255bbd2969: [mlir] Add folding for shape.any
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/test/Dialect/Shape/canonicalize.mlir | ||
---|---|---|
154 | Can you expand a bit on this "yet"? Is that a direction we want to go? It seems like it would be a very small change to this patch to support that, suggesting there is a deeper reason why we want to avoid that, which would be good to document here or in AnyOp::fold |
mlir/lib/Dialect/Shape/IR/Shape.cpp | ||
---|---|---|
106 | So the folder only focuses on case where the output can be fully statically computed? [this overlaps with Sean's question below] | |
108 | Nit: Perhaps expand the comment slightly: it is commutative and so constants have been moved to the trailing operands. This would be known to someone who read the canonicalization doc or looked at FoldUtils.cpp , but I think it is useful to avoid needing that context especially as short. |
mlir/test/Dialect/Shape/canonicalize.mlir | ||
---|---|---|
154 | We would need to inspect operands and their types for this to work, which is more complex than just looking at constant operands. So it makes sense to land this first, if only to support static shape workloads, and expand later. A comment like Folding of any with partially constant operands is not yet implemented should convey this. |
mlir/lib/Dialect/Shape/IR/Shape.cpp | ||
---|---|---|
106 | Yes, I started to add that as a comment, but then realized that's essentially the definition of folding, so I think it would be redundant to state. | |
mlir/test/Dialect/Shape/canonicalize.mlir | ||
154 | There's a not a specific reason to not support it. I would rather wait until there's a clear use case though to implement more of this as it's more risky given the inherent lack of safety in the operation. |
So the folder only focuses on case where the output can be fully statically computed? [this overlaps with Sean's question below]