gemini-code-assist[bot] commented on code in PR #19989:
URL: https://github.com/apache/tvm/pull/19989#discussion_r3566125105
##########
tests/python/relax/test_frontend_from_exported_program.py:
##########
@@ -8281,8 +8287,8 @@ def main(input: R.Tensor((9, 9), dtype="float32")) ->
R.Tuple(
)
def test_dtypes(torch_dtype, relax_dtype):
example_args = (
- torch.randint(0, 10, (10, 10)).to(torch_dtype),
- torch.randint(0, 10, (10, 10)).to(torch_dtype),
+ torch.testing.make_tensor((10, 10), dtype=torch_dtype, device="cpu",
low=0, high=10),
+ torch.testing.make_tensor((10, 10), dtype=torch_dtype, device="cpu",
low=0, high=10),
)
Review Comment:

Using `low` and `high` arguments with `torch.testing.make_tensor` when
`dtype` is `torch.bool` will raise a `ValueError` in PyTorch (e.g.,
`ValueError: Cannot set low or high for boolean dtypes`). Since `test_dtypes`
is parameterized with `torch.bool`, this will cause the test to fail.
We should conditionally set these parameters only when the data type is not
boolean.
```suggestion
kwargs = {"low": 0, "high": 10} if torch_dtype != torch.bool else {}
example_args = (
torch.testing.make_tensor((10, 10), dtype=torch_dtype, device="cpu",
**kwargs),
torch.testing.make_tensor((10, 10), dtype=torch_dtype, device="cpu",
**kwargs),
)
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]