haojin2 commented on a change in pull request #15519: [Numpy] arctan2, a new branch for pr. URL: https://github.com/apache/incubator-mxnet/pull/15519#discussion_r302928599
########## File path: tests/python/gpu/test_operator_gpu.py ########## @@ -2300,6 +2300,81 @@ def test_math(): for op in ops: run_math(op, shape, dtype, check_value=check_value) +@with_seed() +@npx.use_np_shape +def test_np_arctan2(): + @npx.use_np_shape + class TestArctan2(HybridBlock): + def __init__(self): + super(TestArctan2, self).__init__() + + def hybrid_forward(self, F, x1, x2): + return F.np.arctan2(x1, x2) + + #Reduce dimension of src to dimention of des. + def dimReduce(src, des): + srcShape = src.shape + desShape = des.shape + if len(desShape) == 0: + return src.sum() + redu = [] + for i, j in zip(range(len(srcShape)-1, -1, -1), range(len(desShape)-1, -1, -1)): + if srcShape[i] != desShape[j] and desShape[j] == 1: + redu.append(i) + if j == 0: + for k in range(0, i): + redu.append(k) + break + if len(redu) > 0: + src = np.reshape(src.sum(axis=tuple(redu)), desShape) + return src + + types = ['float64', 'float32', 'float16'] + for hybridize in [True, False]: + for shape1, shape2 in [[(1,), (1,)], # single elements + [(4, 5), (4, 5)], # normal case + [(3, 2), (3, 2)], # tall matrices + [(), ()], # scalar only + [(3, 0, 2), (3, 0, 2)], # zero-dim + [(3, 4, 5), (4, 1)], # trailing dim broadcasting + [(3, 4, 5), ()], # scalar broadcasting + [(), (1, 2, 3)], # scalar broadcasting + [(4, 3), (4, 1)], # single broadcasting + [(3, 4, 5), (3, 1, 5)] # single broadcasting in the middle + ]: Review comment: Align lines: ```python for shape1, shape2 in [[(1,), (1,)], # single elements [(4, 5), (4, 5)], # normal case [(3, 2), (3, 2)], # tall matrices [(), ()], # scalar only [(3, 0, 2), (3, 0, 2)], # zero-dim [(3, 4, 5), (4, 1)], # trailing dim broadcasting [(3, 4, 5), ()], # scalar broadcasting [(), (1, 2, 3)], # scalar broadcasting [(4, 3), (4, 1)], # single broadcasting [(3, 4, 5), (3, 1, 5)] # single broadcasting in the middle ]: ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services