-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix erfinv and swapaxes #7217
Fix erfinv and swapaxes #7217
Changes from 6 commits
5d141b3
8b3542f
4838ebd
592c490
75fcc2e
e2f2d70
45986a3
f76a57b
e06577f
59477b8
01b4f47
260dca8
c6e8f4a
be5b254
7f1e2be
51ada35
9d4c402
94ade39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,35 @@ | |
from oneflow.test_utils.automated_test_util import * | ||
|
||
|
||
def _test_flow_erfinv_with_1_data(test_case, device): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _test_flow_erfinv_with_inf_data |
||
x = flow.tensor(np.ones((5, 5)), dtype=flow.float32, device=flow.device(device)) | ||
of_out = flow.erfinv(x) | ||
np_out = np.full((5, 5), np.inf) | ||
test_case.assertTrue(np.array_equal(of_out.numpy(), np_out)) | ||
|
||
|
||
def _test_flow_erfinv_with_gt_1_data(test_case, device): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _test_flow_erfinv_with_nan_data |
||
x = flow.tensor( | ||
np.arange(2, 22).reshape(4, 5), dtype=flow.float32, device=flow.device(device) | ||
) | ||
np_out = np.full((4, 5), np.nan) | ||
of_out = ",".join(str(i) for i in flow.erfinv(x).numpy()) | ||
np_out = ",".join(str(i) for i in np_out) | ||
test_case.assertEqual(of_out, np_out) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np.array_equal(of_out.numpy(), np_out, equal_nan=True) |
||
|
||
|
||
@flow.unittest.skip_unless_1n1d() | ||
class TestErfinvModule(flow.unittest.TestCase): | ||
def test_flow_erfinv(test_case): | ||
arg_dict = OrderedDict() | ||
arg_dict["test_fun"] = [ | ||
_test_flow_erfinv_with_1_data, | ||
_test_flow_erfinv_with_gt_1_data, | ||
] | ||
arg_dict["device"] = ["cpu", "cuda"] | ||
for arg in GenArgList(arg_dict): | ||
arg[0](test_case, *arg[1:]) | ||
|
||
@autotest(check_graph=True, auto_backward=False) | ||
def test_flow_erfinv_with_random_data(test_case): | ||
device = random_device() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个改动的目的是什么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和Pytorch的CPU版本erfinv严格对齐