Zha0q1 commented on a change in pull request #19059:
URL: https://github.com/apache/incubator-mxnet/pull/19059#discussion_r489115654
##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -568,6 +502,517 @@ def test_slice_assign():
B[-1] = 2
assert B[-1, 0] == 2 and B[-1, 1] == 2
+@use_np
+def test_logical_family():
+ def batch_check(x1, x2, funcs):
+ x1.attach_grad()
+ for f in funcs:
+ with mx.autograd.record():
+ y = f(x1, x2)
+ y.backward()
+ assert y.shape == x1.shape
+ assert y[0] == f(x1[0], x2[0])
+ assert x1.grad.shape == x1.shape
+ assert x1.grad[0] == 0
+
+ A = np.zeros((INT_OVERFLOW), dtype='int32')
+ B = np.ones((INT_OVERFLOW), dtype='int32')
+ batch_check(A, B, [np.logical_and, np.logical_or, np.logical_xor])
+ B.attach_grad()
+ with mx.autograd.record():
+ C = np.logical_not(B)
+ C.backward()
+ assert C.shape == B.shape
+ assert C[0] == 0
+ assert B.grad.shape == B.shape
+ assert B.grad[0] == 0
+
+@use_np
+def test_deg_rad():
+ # deg2rad is the same thing as radians
+ # rad2deg is the same thing as degrees
+ A = np.zeros((INT_OVERFLOW, 2))
+ A[-1, -1] = 180
+ A.attach_grad()
+ with mx.autograd.record():
+ B = np.deg2rad(A)
+ B.backward()
+ assert B.shape == A.shape
+ assert B[0, 0] == 0
+ assert_almost_equal(B[-1, -1], np.array([np.pi]), rtol=1e-5, atol=1e-5)
+ assert A.grad.shape == A.shape
+ assert_almost_equal(A.grad[0, 0], np.array([1.0 / 180 * np.pi]),
rtol=1e-5, atol=1e-5)
Review comment:
It's actual 1.0 / 180 * np.pi since rad = deg / 180 * pi
----------------------------------------------------------------
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]