haojin2 commented on a change in pull request #17254: [numpy] change unary
infer type
URL: https://github.com/apache/incubator-mxnet/pull/17254#discussion_r364604506
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -1832,6 +1832,35 @@ def hybrid_forward(self, F, a, *args, **kwargs):
funcs = {
'absolute' : (lambda x: -1. * (x < 0) + (x > 0), -1.0, 1.0),
+ 'logical_not' : (None, -1.0, 1.0),
+ 'negative' : (lambda x: -1. * _np.ones(x.shape), -1.0, 1.0),
+ 'reciprocal' : (lambda x: -1. / (x ** 2), 0.01, 1.0),
+ 'sign' : (None, -1.0, 1.0),
+ 'square' : (lambda x: 2.0 * x, -1.0, 1.0),
+ }
+ if has_tvm_ops():
+ funcs['rad2deg'] = (lambda x: 180. / _np.pi * _np.ones(x.shape), -1.0,
1.0)
+ funcs['deg2rad'] = (lambda x: _np.pi / 180. * _np.ones(x.shape), -1.0,
1.0)
+ ndim = random.choice([2, 3, 4])
+ shape = random.choice([rand_shape_nd(ndim, dim=3), (1, 0, 2)])
+ for shape in [rand_shape_nd(ndim, dim=3), (1, 0, 2)]:
+ for func, func_data in funcs.items():
+ ref_grad, low, high = func_data
+ check_unary_func(func, ref_grad, shape, low, high)
+
+@with_seed()
Review comment:
1 more blank line above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services