[Mlir-commits] [mlir] Add examples for reinterpret_cast and subview operators to show their behavior in relation to their input memref underlying memory and view (PR #135244)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Apr 24 12:16:31 PDT 2025
================
@@ -1363,6 +1363,58 @@ def MemRef_ReinterpretCastOp
%dst.sizes = %sizes
%dst.strides = %strides
```
+
+ Example 2:
+
+ Consecutive `reinterpret_cast` operations on memref's with static dimensions.
+
+ We distinguish between *underlying memory* — the sequence of elements as
+ they appear in the contiguous memory of the memref — and the *view*, which refers to
+ the underlying memory interpreted according to specified offsets, sizes, and strides.
+
+ ```mlir
+ %result1 = memref.reinterpret_cast %arg0 to offset: [9], sizes: [4, 4], strides: [16, 2] : memref<8x8xf32, strided<[8, 1], offset: 0>> to memref<4x4xf32, strided<[16, 2], offset: 9>>
+
+ %result2 = memref.reinterpret_cast %result1 to offset: [0], sizes: [2, 2], strides: [4, 2] : memref<4x4xf32, strided<[16, 2], offset: 9>> to memref<2x2xf32, strided<[4, 2], offset: 0>>
+ ```
+
+ The input memref `%arg0` has the following view. The underlying memory consists
----------------
ivangarcia44 wrote:
Replaced this:
The input memref `%arg0` has the following view. The underlying memory
consists of a linear sequence of integers from 1 to 64:
With this:
The underlying memory consists of a linear sequence of integers from
1 to 64. The memref %arg0 has the following 8x8 elements:
https://github.com/llvm/llvm-project/pull/135244
More information about the Mlir-commits
mailing list