wrongtest opened a new pull request #10582: URL: https://github.com/apache/tvm/pull/10582
- After https://github.com/apache/tvm/pull/9727, the low level TIR memory access is on `Buffer` objects. The `Buffer` has `elem_offset` https://github.com/apache/tvm/blob/e34985b5b89e13cbbb7ebddee1ec5c1470a952f6/include/tvm/tir/buffer.h#L79-L80 Thus the addressing rule for `BufferLoad`, `BufferStore` and `T.address_of` should also take this offset field into consideration. - Also, the buffer combine functionality in `StorageRewrite` pass currently create alias buffers to the alloc buffer var, which denotes the start offset of the merged buffer. But it seems illness since the alias buffer's accessed indices exceed the alias buffer extent. ```python # example from ut @T.prim_func def func(A: T.Buffer[(4,), "float32"], A4: T.Buffer[(8,), "float32"]) -> None: A0 = T.allocate([16], "float32", "global:tag") A0_1 = T.buffer_decl([8], dtype="float32", data=A0.data, scope="global:tag") A0_2 = T.buffer_decl([8], dtype="float32", data=A0.data, scope="global:tag") A0_3 = T.buffer_decl([8], dtype="float32", data=A0.data, scope="global:tag") A0_4 = T.buffer_decl([8], dtype="float32", data=A0.data, scope="global:tag") for i in T.serial(8): A0_1[i] = A[i] + A[0] + T.float32(1) for i in T.serial(8): A0_2[8 + i] = A0_1[i] + A0_1[0] + T.float32(2) for i in T.serial(8): A0_3[i] = A0_2[8 + i] + A0_2[8] + T.float32(3) for i in T.serial(8): A0_4[8 + i] = A0_3[i] + A0_3[0] + T.float32(4) for i in T.serial(8): A4[i] = A0_4[8 + i] + A0_4[8] + T.float32(5) ``` It would be great to set `elem_offset` to alias buffers, thus each alias buffer's address range is marked explicitly. ```python @T.prim_func def func(A: T.Buffer[(4,), "float32"], A4: T.Buffer[(8,), "float32"]) -> None: A0 = T.allocate([16], "float32", "global:tag") A0_1 = T.buffer_decl([8], dtype="float32", data=A0.data, scope="global:tag") A0_2 = T.buffer_decl([8], dtype="float32", data=A0.data, elem_offset=8, scope="global:tag") A0_3 = T.buffer_decl([8], dtype="float32", data=A0.data, scope="global:tag") A0_4 = T.buffer_decl([8], dtype="float32", data=A0.data, elem_offset=8, scope="global:tag") for i in T.serial(8): A0_1[i] = A[i] + A[0] + T.float32(1) for i in T.serial(8): A0_2[i] = A0_1[i] + A0_1[0] + T.float32(2) for i in T.serial(8): A0_3[i] = A0_2[i] + A0_2[0] + T.float32(3) for i in T.serial(8): A0_4[i] = A0_3[i] + A0_3[0] + T.float32(4) for i in T.serial(8): A4[i] = A0_4[i] + A0_4[0] + T.float32(5) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
