Fix assumption on memref element type being int/float in memref elt size
related method and affine data copy generate.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Dialect/Affine/Analysis/Utils.h | ||
---|---|---|
382 | For index-typed memrefs and for memrefs in general, at this stage, we don't have layout information. So this is really returning a tentative or a "best-effort" size, which is what the clients of this method (affine passes) desire. This is being exposed from MLIR Affine Analysis library since it has at least two users among affine passes/utilities. In general, the clients are expected to be aware that this size may not be the final size of the buffer which may be layout/backend dependent. |
mlir/include/mlir/Dialect/Affine/Analysis/Utils.h | ||
---|---|---|
382 | If this is called from the pass, it may be possible to obtain the DataLayoutAnalysis in the pass from the analysis manager, and query it for the DataLayout object of the module. Given that, this should be able to compute the element size the same way the allocation lowering does. Otherwise, I'd call it getMemRefIntOrFloatEltSizeInBytes, or something similar that indicates it being only suitable for ints, floats and vectors thereof. |
mlir/include/mlir/Dialect/Affine/Analysis/Utils.h | ||
---|---|---|
382 | Thanks. Renamed to getMemRefIntOrFloatEltSizeInBytes. This is used from a free-standing utility in Affine LoopUtils although it's eventually used from passes in the upstream repo. It's expected to be used from other utilities downstream. |
mlir/lib/Dialect/Affine/Analysis/Utils.cpp | ||
---|---|---|
607 | I'm not sure whether this approach is correct. But we assume the index type bit-width is set by kInternalStorageBitWidth, which is already used in the several parts. https://reviews.llvm.org/D146019 Can we simply use this value for calculating the memref size as well? |
mlir/lib/Dialect/Affine/Analysis/Utils.cpp | ||
---|---|---|
607 | Note that isIntOrFloat returns false for index types. So, we are returning nullopt (i.e., failing this method) when an provide an index typed memref is provided. It would be wrong to use a specific value since the width of index depends on the lowering target - it can be 32 bits, 64 bits or anything else. |
mlir/lib/Dialect/Affine/Analysis/Utils.cpp | ||
---|---|---|
607 |
As the name suggests, it is supposed to be used for internal storage. Please don't use it beyond that. Using the DataLayout is the right approach, and we do have platforms on which index is lowered to a type with a smaller width than the internal storage. |
@ftynse I'm not sure this should be exposed from here or if there's something else I should use or if this should be renamed to something specific.