Lunderberg commented on issue #17270:
URL: https://github.com/apache/tvm/issues/17270#issuecomment-2299446438
The inconsistent results occur even if the `FoldConstant` and
`ReorderTakeAfterMatmul` lines are removed. This looks like there's some
out-of-bounds access in the PrimFuncs. If I replace the TIR functions with
their Relax equivalents, I get something as follows, which shows the same
inconsistent outputs:
```python
class Module:
@R.function
def main():
metadata_constant = R.reshape(R.arange(256), [16,
16]).astype("float32")
weight_table: R.Tensor([16, 16], "float32") = metadata_constant +
metadata_constant
x = R.strided_slice(
R.reshape(weight_table, [256]),
axes=[0],
begin=[0],
end=[16],
)
indices = weight_table.astype("int64")
routing_table = R.strided_slice(
R.reshape(indices, [256]),
axes=[0],
begin=[0],
end=[32],
)
weight = R.take(weight_table, routing_table, axis=1)
out = R.matmul(x, weight)
return out
```
The initial constant from the metadata has values within `[0,256)`. After
adding it to itself and taking the first 32 indices, the values range from
`[0,64)`. However, the weight table is of shape `[16,16]`, and these indices
are used to access axis 1. This out-of-bounds access results in inconsistent
outputs.
--
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]