diff --git a/mindspore/ops/operations/thor_ops.py b/mindspore/ops/operations/thor_ops.py index f84b5d1ffd..d2de0190a6 100644 --- a/mindspore/ops/operations/thor_ops.py +++ b/mindspore/ops/operations/thor_ops.py @@ -13,10 +13,9 @@ # limitations under the License. # ============================================================================ """thor_ops""" -from mindspore.ops import prim_attr_register, PrimitiveWithInfer -from mindspore.ops.composite import multitype_ops as C +from ..primitive import prim_attr_register, PrimitiveWithInfer +from ...common import dtype as mstype -import mindspore as ms __all__ = ["CusBatchMatMul", "CusCholeskyTrsm", @@ -58,11 +57,6 @@ class CusBatchMatMul(PrimitiveWithInfer): """init CusBatchMatMul""" self.init_prim_io_names(inputs=['x1', 'x2'], outputs=['y']) from mindspore.ops._op_impl._custom_op.batch_matmul_impl import CusBatchMatMul - def get_bprop(self): - def bprop(x1, x2, out, dout): - return (C.zeros_like(x1), C.zeros_like(x2)) - - return bprop def infer_shape(self, data1_shape, data2_shape): return data1_shape @@ -97,11 +91,6 @@ class CusCholeskyTrsm(PrimitiveWithInfer): self.init_prim_io_names(inputs=['x1'], outputs=['y']) from mindspore.ops._op_impl._custom_op.cholesky_trsm_impl import CusCholeskyTrsm - def get_bprop(self): - def bprop(x, out, dout): - return (C.zeros_like(x),) - return bprop - def infer_shape(self, data1_shape): ll = [] m, _ = data1_shape @@ -138,11 +127,6 @@ class CusFusedAbsMax1(PrimitiveWithInfer): self.init_prim_io_names(inputs=['x1'], outputs=['y']) self.origin_shape = origin_shape from mindspore.ops._op_impl._custom_op.fused_abs_max1_impl import CusFusedAbsMax1 - def get_bprop(self): - def bprop(x, out, dout): - return (C.zeros_like(x),) - - return bprop def infer_shape(self, data1_shape): ll = [] @@ -182,11 +166,6 @@ class CusImg2Col(PrimitiveWithInfer): self.dilates = dilates self.mode = mode from mindspore.ops._op_impl._custom_op.img2col_impl import CusImg2Col - def get_bprop(self): - def bprop(x, out, dout): - return (C.zeros_like(x),) - - return bprop def infer_shape(self, data1_shape): bs, c, h, w = data1_shape @@ -229,17 +208,12 @@ class CusMatMulCubeDenseLeft(PrimitiveWithInfer): """init CusMatMulCubeDenseLeft""" self.init_prim_io_names(inputs=['x1', 'x2'], outputs=['y']) from mindspore.ops._op_impl._custom_op.matmul_cube_dense_left_impl import CusMatMulCubeDenseLeft - def get_bprop(self): - def bprop(x1, x2, out, dout): - return (C.zeros_like(x1), C.zeros_like(x2)) - - return bprop def infer_shape(self, data1_shape, data2_shape): return data2_shape def infer_dtype(self, data1_dtype, data2_dtype): - return ms.common.dtype.tensor_type(getattr(ms, "float16")) + return mstype.float16 class CusMatMulCubeFraczRightMul(PrimitiveWithInfer): @@ -269,17 +243,12 @@ class CusMatMulCubeFraczRightMul(PrimitiveWithInfer): """init CusMatMulCubeFraczRightMul""" self.init_prim_io_names(inputs=['x1', 'x2', 'x3'], outputs=['y']) from mindspore.ops._op_impl._custom_op.matmul_cube_fracz_right_mul_impl import CusMatMulCubeFraczRightMul - def get_bprop(self): - def bprop(x1, x2, x3, out, dout): - return (C.zeros_like(x1), C.zeros_like(x2), C.zeros_like(x3)) - - return bprop def infer_shape(self, data1_shape, data2_shape, data3_shape): return data1_shape def infer_dtype(self, data1_dtype, data2_dtype, data3_dtype): - return ms.common.dtype.tensor_type(getattr(ms, "float32")) + return mstype.float32 class CusMatMulCube(PrimitiveWithInfer): @@ -315,11 +284,6 @@ class CusMatMulCube(PrimitiveWithInfer): self.transpose_a = transpose_a self.transpose_b = transpose_b from mindspore.ops._op_impl._custom_op.matmul_cube_impl import CusMatMulCube - def get_bprop(self): - def bprop(x1, x2, out, dout): - return (C.zeros_like(x1), C.zeros_like(x2)) - - return bprop def infer_shape(self, data1_shape, data2_shape): # shape = [1, data1_shape[1], data2_shape[2], 16, 16] @@ -337,7 +301,7 @@ class CusMatMulCube(PrimitiveWithInfer): return shape def infer_dtype(self, data1_dtype, data2_dtype): - return ms.common.dtype.tensor_type(getattr(ms, "float32")) + return mstype.float32 class CusMatrixCombine(PrimitiveWithInfer): @@ -362,11 +326,6 @@ class CusMatrixCombine(PrimitiveWithInfer): """init CusMatrixCombine""" self.init_prim_io_names(inputs=['x'], outputs=['y']) from mindspore.ops._op_impl._custom_op.matrix_combine_impl import CusMatrixCombine - def get_bprop(self): - def bprop(x, out, dout): - return (C.zeros_like(x),) - - return bprop def infer_shape(self, data_shape): a, b, c = data_shape @@ -446,17 +405,12 @@ class CusMatMulCubeDenseRight(PrimitiveWithInfer): """init CusMatMulCubeDenseRight""" self.init_prim_io_names(inputs=['x1', 'x2', 'x3'], outputs=['y']) from mindspore.ops._op_impl._custom_op.matmul_cube_dense_right_impl import CusMatMulCubeDenseRight - def get_bprop(self): - def bprop(x1, x2, x3, out, dout): - return (C.zeros_like(x1), C.zeros_like(x2), C.zeros_like(x3)) - - return bprop def infer_shape(self, data1_shape, data2_shape, data3_shape): return data1_shape def infer_dtype(self, data1_dtype, data2_dtype, data3_dtype): - return ms.common.dtype.tensor_type(getattr(ms, "float32")) + return mstype.float32 class CusMatMulCubeFraczLeftCast(PrimitiveWithInfer): @@ -486,14 +440,9 @@ class CusMatMulCubeFraczLeftCast(PrimitiveWithInfer): """init CusMatMulCubeFraczLeftCast""" self.init_prim_io_names(inputs=['x1', 'x2'], outputs=['y']) from mindspore.ops._op_impl._custom_op.matmul_cube_fracz_left_cast_impl import CusMatMulCubeFraczLeftCast - def get_bprop(self): - def bprop(x1, x2, out, dout): - return (C.zeros_like(x1), C.zeros_like(x2)) - - return bprop def infer_shape(self, data1_shape, data2_shape): return data2_shape def infer_dtype(self, data1_dtype, data2_dtype): - return ms.common.dtype.tensor_type(getattr(ms, "float16")) + return mstype.float16