-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathcopysign.py
More file actions
76 lines (58 loc) · 1.99 KB
/
Copy pathcopysign.py
File metadata and controls
76 lines (58 loc) · 1.99 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import infinicore
import torch
from framework import BaseOperatorTest, GenericTestRunner, TensorSpec, TestCase
_TEST_CASES_DATA = [
((13, 4), None),
((2, 3, 4), None),
((16, 5632), None),
]
_TOLERANCE_MAP = {
infinicore.float32: {"atol": 0, "rtol": 0},
}
_TENSOR_DTYPES = [infinicore.float32]
def parse_test_cases():
test_cases = []
for shape, strides in _TEST_CASES_DATA:
for dtype in _TENSOR_DTYPES:
input_spec = TensorSpec.from_tensor(shape, strides, dtype, name="input")
other_spec = TensorSpec.from_tensor(shape, strides, dtype, name="other")
out_spec = TensorSpec.from_tensor(shape, None, dtype, name="out")
tolerance = _TOLERANCE_MAP[dtype]
test_cases.append(
TestCase(
inputs=[input_spec, other_spec],
kwargs={},
output_spec=None,
comparison_target=None,
tolerance=tolerance,
description="copysign - OUT_OF_PLACE",
)
)
test_cases.append(
TestCase(
inputs=[input_spec, other_spec],
kwargs={},
output_spec=out_spec,
comparison_target="out",
tolerance=tolerance,
description="copysign - INPLACE(out)",
)
)
return test_cases
class OpTest(BaseOperatorTest):
def __init__(self):
super().__init__("Copysign")
def get_test_cases(self):
return parse_test_cases()
def torch_operator(self, *args, **kwargs):
return torch.copysign(*args, **kwargs)
def infinicore_operator(self, *args, **kwargs):
return infinicore.copysign(*args, **kwargs)
def main():
runner = GenericTestRunner(OpTest)
runner.run_and_exit()
if __name__ == "__main__":
main()