Lunderberg commented on PR #14095:
URL: https://github.com/apache/tvm/pull/14095#issuecomment-1441044009
It looks like this would also allow index maps that reduce the number of
elements in a buffer. For example, if I use the transform `lambda i, j: [i %
2, j]`, I'd expect to receive an error, because I've reduced the buffer size
from `[N, M]` to `[2, M]`. I put together a quick unit test (below), and
```python
class TestNonInjectiveTransform(BasePaddingCompare):
"""Each location must map to a unique transformed location"""
index_map = tvm.testing.parameter(lambda i, j: [i % 2, j])
def before():
A = T.alloc_buffer((4, 4), "int32")
for i, j in T.grid(4, 4):
with T.block("block"):
vi, vj = T.axis.remap("SS", [i, j])
A[vi, vj] = 0
expected = tvm.tir.schedule.schedule.ScheduleError
```
No error is thrown, and I instead get the following output.
```python
@T.prim_func
def after():
A = T.alloc_buffer((2, 4), "int32")
for i, j in T.grid(4, 4):
with T.block("block"):
vi, vj = T.axis.remap("SS", [i, j])
T.reads()
T.writes(A[vi % 2, vj])
A[vi % 2, vj] = 0
```
This could be useful, as several other primitives could then be expressed in
terms of a buffer transform, which may reduce complexity (e.g. This `lambda
i,j: [i%2, j]` transformation could be used to implement double-buffering), but
it could also have a large effect on any of the consumers of `A`.
--
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]