Skip to content

Commit

Permalink
fix: make elemwise test check against dtype in the graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrine committed Aug 13, 2024
1 parent 584e506 commit fe0a7ec
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/tensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,17 @@ def test_good(self):
if not isinstance(expecteds, list | tuple):
expecteds = (expecteds,)

for i, (variable, expected) in enumerate(zip(variables, expecteds)):
for i, (variable, expected, out_symbol) in enumerate(
zip(variables, expecteds, node.outputs)
):
condition = (
variable.dtype != expected.dtype
variable.dtype != out_symbol.type.dtype
or variable.shape != expected.shape
or not np.allclose(variable, expected, atol=eps, rtol=eps)
)
assert not condition, (
f"Test {self.op}::{testname}: Output {i} gave the wrong"
f" value. With inputs {inputs}, expected {expected} (dtype {expected.dtype}),"
f" value. With inputs {inputs}, expected {expected} (dtype {out_symbol.type.dtype}),"
f" got {variable} (dtype {variable.dtype}). eps={eps:f}"
f" np.allclose returns {np.allclose(variable, expected, atol=eps, rtol=eps)} {np.allclose(variable, expected)}"
)
Expand Down

0 comments on commit fe0a7ec

Please sign in to comment.