Skip to content

Commit

Permalink
quant: throw a nice error message for allclose with quantized inputs
Browse files Browse the repository at this point in the history
Summary:

Currently `torch.allclose` is not supported with quantized inputs.
Throw a nice error message instead of a cryptic one.

Test Plan:

```
torch.allclose(x_fp32, y_fp32)

torch.allclose(x_int8, y_int8)
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: fbe9612c42591dd4e5c349a9d1d83e1749fc247c
Pull Request resolved: #49802
  • Loading branch information
vkuzo committed Dec 30, 2020
1 parent 6a951a6 commit 4e4044e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aten/src/ATen/native/TensorCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Tensor isclose(const Tensor& self, const Tensor& other, double rtol, double atol
TORCH_CHECK(self.scalar_type() == other.scalar_type(), self.scalar_type(), " did not match ", other.scalar_type());
TORCH_CHECK(!(self.is_complex() && equal_nan),
"isclose with equal_nan=True is not supported for complex inputs.");
TORCH_CHECK(!(self.is_quantized() || other.is_quantized()),
"isclose is not supported for quantized inputs.");

// Checks that rtol and atol are non-negative
// Note: consistent with Python's isclose but divergent from NumPy's, which
Expand Down

0 comments on commit 4e4044e

Please sign in to comment.