Extended promote buffers to stack pass to support dynamically shaped allocas.
The conversion is limited by the rank of the underlying tensor.
An option is added to the pass to adjust the given rank.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Transforms/Passes.td | ||
---|---|---|
216 | I would remove "Define the" from all these 3 options. Just Maximal size in bytes to promote allocations to stack. | |
mlir/lib/Transforms/BufferOptimizations.cpp | ||
39–40 | nit: please, write this in one line: | |
322 | would it work with Operation* instead of auto? then you wouldn't need to write getOperation() below. |
Thanks. Just some nits.
mlir/include/mlir/Transforms/Passes.td | ||
---|---|---|
222 | Can you describe this in more detail? Not all buffers that have less than this rank will be promoted but only "small" ones. | |
mlir/lib/Transforms/BufferOptimizations.cpp | ||
35 | I think we we should limit this to alloc where the defining op is an AllocOp as otherwise we likely do not want to do this transformation. | |
44 | Would return operand.getDefiningOp<RankOp>() also work? | |
mlir/test/Transforms/promote-buffers-to-stack.mlir | ||
112 | Can you add a check where this is more than 3? |
Addressed comments.
Changed default max rank to 1 instead of 2 and changed condition to less or equal.
This way is more intuitive.
mlir/test/Transforms/promote-buffers-to-stack.mlir | ||
---|---|---|
112 | I added another test pass that checks this behaviour. An extra test for this is redundant and skipped. |
mlir/lib/Transforms/BufferOptimizations.cpp | ||
---|---|---|
39 | nit: I feel like this comment should read "if the dynamic dimension of the alloc is produced by a RankOp, then we know it is likely to be small. Also limit this to maxRankOfTensors to prevent multiple small values produced by RankOp from multiplying to an excessively large value" |
mlir/test/Transforms/promote-buffers-to-stack.mlir | ||
---|---|---|
104 | nit: why does this test need control flow? this patch seems like a very localized change unrelated to control flow. |
I would remove "Define the" from all these 3 options. Just
Maximal size in bytes to promote allocations to stack.
Bitwidth of the index type. Used for size estimation.
Maximal tensor rank to promote dynamic buffers.