Skip to content

Commit

Permalink
quant: throw a nice error message for allclose with quantized inputs (p…
Browse files Browse the repository at this point in the history
…ytorch#49802)

Summary:
Pull Request resolved: pytorch#49802

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)
```

Imported from OSS

Reviewed By: supriyar

Differential Revision: D25693538

fbshipit-source-id: 8958628433adfca3ae6ce215f3e3ec3c5e29994c
  • Loading branch information
vkuzo authored and hwangdeyu committed Jan 14, 2021
1 parent 499f740 commit 8d51789
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 8d51789

Please sign in to comment.