def __init__(self): super(NetAcosh, self).__init__() self.acosh = P.Acosh()
'desc_bprop': [[2, 3]]}), ('Erf', { 'block': P.Erf(), 'desc_inputs': [Tensor(np.array([-2, -1, 0, 1, 2]).astype(np.float16))], 'desc_bprop': [Tensor(np.array([-2, -1, 0, 1, 2]).astype(np.float16))]}), ('Floor', { 'block': P.Floor(), 'desc_inputs': [[2, 512, 56, 56]], 'desc_bprop': [[2, 512, 56, 56]], 'skip': ['backward']}), ('ACos', { 'block': P.ACos(), 'desc_inputs': [[2, 3]], 'desc_bprop': [[2, 3]]}), ('Acosh', { 'block': P.Acosh(), 'desc_inputs': [Tensor(np.random.rand(4).astype(np.float16))], 'skip': ['backward']}), ('Sin', { 'block': P.Sin(), 'desc_inputs': [[2, 3]], 'desc_bprop': [[2, 3]]}), ('Reciprocal', { 'block': P.Reciprocal(), 'desc_inputs': [[2, 3, 3, 5]], 'desc_bprop': [[2, 3, 3, 5]]}), ('Minimum_0', { 'block': P.Minimum(), 'desc_inputs': [[2, 3, 3, 5], [3, 3, 5]], 'desc_bprop': [[2, 3, 3, 5]]}), ('Maximum', {
'desc_inputs': [5.0, Tensor(np.ones([3, 4]).astype(np.float32))], 'skip': ['backward']}), # input two tensors, but element types are not same ('FloorMod1', { 'block': (P.FloorMod(), {'exception': TypeError, 'error_keywords': ['FloorMod']}), 'desc_inputs': [Tensor(np.ones([3, 4]).astype(np.int32)), Tensor(np.ones([3, 4]).astype(np.float32))], 'skip': ['backward']}), # input two tensors, their shapes do not match ('FFloorMod2', { 'block': (P.FloorMod(), {'exception': ValueError, 'error_keywords': ['FloorMod']}), 'desc_inputs': [Tensor(np.ones([3, 5]).astype(np.float32)), Tensor(np.ones([3, 4]).astype(np.float32))], 'skip': ['backward']}), # input x is Tensor(int32), not Tensor(float) ('Acosh1', { 'block': (P.Acosh(), {'exception': TypeError, 'error_keywords': ['Acosh']}), 'desc_inputs': [Tensor(np.ones([2, 3]).astype(np.bool_))], 'skip': ['backward']}), # input is not tensor ('Equal0', { 'block': (P.Equal(), {'exception': TypeError, 'error_keywords': ['Equal']}), 'desc_inputs': [5.0, Tensor(np.ones([3, 4]).astype(np.float32))], 'skip': ['backward']}), # type of x and y not match ('Equal1', { 'block': (P.Equal(), {'exception': TypeError, 'error_keywords': ['Equal']}), 'desc_inputs': [Tensor(np.ones([3, 4]).astype(np.int32)), Tensor(np.ones([3, 4]).astype(np.float32))], 'skip': ['backward']}), # shape of x and y not match
def __init__(self, strategy1, strategy2): super().__init__() self.matmul = P.MatMul().set_strategy(strategy1) self.acosh = P.Acosh().set_strategy(strategy2) self.matmul2 = P.MatMul().set_strategy(strategy1)
def test_acosh_fp16(): x_np = np.random.rand(4, 2).astype(np.float16) * 10 + 1 output_ms = P.Acosh()(Tensor(x_np)) output_np = np.arccosh(x_np.astype(np.float32)).astype(np.float16) assert np.allclose(output_ms.asnumpy(), output_np, 1e-3, 1e-3)