forked from NVIDIA/Fuser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_nan.py
35 lines (29 loc) · 941 Bytes
/
test_nan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
import torch
from nvfuser import FusionDefinition, DataType
def test_validate_precomputed_values():
def compare() -> FusionDefinition:
with FusionDefinition() as fd:
T0 = fd.define_tensor(
shape=[-1, -1],
contiguity=[True, True],
dtype=DataType.Float,
is_cpu=False,
)
S1 = fd.define_scalar(None, dtype=DataType.Double)
T2 = fd.ops.ge(T0, S1)
fd.add_output(T2)
return fd
fd = compare()
outs = fd.execute(
[
torch.randn((10,), dtype=torch.float32, device="cuda:0").as_strided(
(2, 5), (5, 1)
),
float("nan"),
]
)
# Cmoparing any number to NaN results in False.
torch.testing.assert_close(outs[0].cpu(), torch.full((2, 5), False))
if __name__ == "__main__":
pytest.main(["-v", __file__])