diff --git a/mindspore/ops/__init__.py b/mindspore/ops/__init__.py index 0e6c114566a36908e833ff8dafe1d1054b698d48..01ca039862bfcb2b32d082575bf22d78bb32c048 100644 --- a/mindspore/ops/__init__.py +++ b/mindspore/ops/__init__.py @@ -30,7 +30,7 @@ Note: from .primitive import Primitive, PrimitiveWithInfer, prim_attr_register from .vm_impl_registry import get_vm_impl_fn, vm_impl_registry -from .op_info_register import op_info_register, AiCPURegOp, TBERegOp, DataType +from .op_info_register import op_info_register, AkgRegOp, AiCPURegOp, TBERegOp, DataType from .primitive import constexpr from .._c_expression import signature_rw, signature_kind @@ -40,6 +40,6 @@ __primitive__ = [ ] __all__ = ["get_vm_impl_fn", "vm_impl_registry", - "op_info_register", "AiCPURegOp", "TBERegOp", "DataType", + "op_info_register", "AkgRegOp", "AiCPURegOp", "TBERegOp", "DataType", "constexpr"] __all__.extend(__primitive__) diff --git a/mindspore/ops/_op_impl/akg/gpu/cast.py b/mindspore/ops/_op_impl/akg/gpu/cast.py index fb4b221be6471537e369c891cbd795c93ab54ea9..b9ce4cf464e19783c775e8df163ffc44174a61b0 100644 --- a/mindspore/ops/_op_impl/akg/gpu/cast.py +++ b/mindspore/ops/_op_impl/akg/gpu/cast.py @@ -13,45 +13,19 @@ # limitations under the License. """Cast op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "Cast", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - { - "name": "dst_type", - "param_type": "required", - "type": "str" - } - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float16", "float32" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +cast_op_info = AkgRegOp("Cast") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .attr("dst_type", "required", "str") \ + .dtype_format(DataType.F16_Default, DataType.F32_Default) \ + .dtype_format(DataType.F32_Default, DataType.F16_Default) \ + .get_op_info() + + +@op_info_register(cast_op_info) def _cast_akg(): """Cast AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/equal.py b/mindspore/ops/_op_impl/akg/gpu/equal.py index c6cffdad24f3eca401acee9a8c9fb34f9923d2d2..fa20392411d7c4ad458fac4978f862c7b825115a 100644 --- a/mindspore/ops/_op_impl/akg/gpu/equal.py +++ b/mindspore/ops/_op_impl/akg/gpu/equal.py @@ -13,50 +13,19 @@ # limitations under the License. """Equal op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "Equal", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - }, - { - "index": 1, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "y" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "bool", "bool" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +equal_op_info = AkgRegOp("Equal") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .input(1, "y") \ + .output(0, "output") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.BOOL_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.BOOL_Default) \ + .get_op_info() + + +@op_info_register(equal_op_info) def _equal_akg(): """Equal AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/hsigmoid.py b/mindspore/ops/_op_impl/akg/gpu/hsigmoid.py index 29dd8d6251514c3169e37ee3e510ef142abb1c95..31fe3322063efc23b336c1a87a21dc3af86213d8 100644 --- a/mindspore/ops/_op_impl/akg/gpu/hsigmoid.py +++ b/mindspore/ops/_op_impl/akg/gpu/hsigmoid.py @@ -13,40 +13,18 @@ # limitations under the License. """HSigmoid op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "HSigmoid", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +hsigmoid_op_info = AkgRegOp("HSigmoid") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .get_op_info() + + +@op_info_register(hsigmoidgrad_op_info) def _hsigmoid_akg(): """HSigmoid AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/hsigmoid_grad.py b/mindspore/ops/_op_impl/akg/gpu/hsigmoid_grad.py index d29df9c946a1d3e60b2d9fc7e0871b596de55124..39b819138e6d2f3195ba466a214ac9c79cbbb48b 100644 --- a/mindspore/ops/_op_impl/akg/gpu/hsigmoid_grad.py +++ b/mindspore/ops/_op_impl/akg/gpu/hsigmoid_grad.py @@ -13,50 +13,19 @@ # limitations under the License. """HSigmoidGrad op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "HSigmoidGrad", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "y_grad" - }, - { - "index": 1, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +hsigmoidgrad_op_info = AkgRegOp("HSigmoidGrad") \ + .fusion_type("OPAQUE") \ + .input(0, "y_grad") \ + .input(1, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \ + .dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \ + .get_op_info() + + +@op_info_register(hsigmoidgrad_op_info) def _hsigmoid_grad_akg(): """HSigmoidGrad AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/hswish.py b/mindspore/ops/_op_impl/akg/gpu/hswish.py index 619575920fd7050be3ddf491ada901153b61d0bd..17364de6cbfbb1831f06984feb4ff2f90f064c9c 100644 --- a/mindspore/ops/_op_impl/akg/gpu/hswish.py +++ b/mindspore/ops/_op_impl/akg/gpu/hswish.py @@ -13,40 +13,18 @@ # limitations under the License. """HSwish op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "HSwish", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +hswish_op_info = AkgRegOp("HSwish") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .get_op_info() + + +@op_info_register(hsigmoidgrad_op_info) def _hswish_akg(): """HSwish AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/hswish_grad.py b/mindspore/ops/_op_impl/akg/gpu/hswish_grad.py index 6d3556b969d695a6dc56f17da0ed28c05f08a8bd..503dd9a5f1a80d705300f51bfe3058d931f04688 100644 --- a/mindspore/ops/_op_impl/akg/gpu/hswish_grad.py +++ b/mindspore/ops/_op_impl/akg/gpu/hswish_grad.py @@ -13,50 +13,19 @@ # limitations under the License. """HSwishGrad op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "HSwishGrad", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "y_grad" - }, - { - "index": 1, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +hswishgrad_op_info = AkgRegOp("HSwishGrad") \ + .fusion_type("OPAQUE") \ + .input(0, "y_grad") \ + .input(1, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \ + .dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \ + .get_op_info() + + +@op_info_register(hsigmoidgrad_op_info) def _hswish_grad_akg(): """HSwishGrad AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/mean.py b/mindspore/ops/_op_impl/akg/gpu/mean.py index 244af290bb4535f0cd89e01e668611dc003c0a84..b46b701b91712138b4a959208ea280532a4000c1 100644 --- a/mindspore/ops/_op_impl/akg/gpu/mean.py +++ b/mindspore/ops/_op_impl/akg/gpu/mean.py @@ -13,40 +13,18 @@ # limitations under the License. """SimpleMean op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "SimpleMean", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +mean_op_info = AkgRegOp("SimpleMean") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(mean_op_info) def _simple_mean_akg(): """SimpleMean AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/mean_grad.py b/mindspore/ops/_op_impl/akg/gpu/mean_grad.py index 27c0674632162a2ceb63ecf71ebbfca28685e741..e3e0121c20044c7ced78f33d778992726a8bb74e 100644 --- a/mindspore/ops/_op_impl/akg/gpu/mean_grad.py +++ b/mindspore/ops/_op_impl/akg/gpu/mean_grad.py @@ -13,45 +13,19 @@ # limitations under the License. """SimpleMeanGrad op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "SimpleMeanGrad", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - { - "name": "input_shape", - "param_type": "required", - "type": "listInt" - } - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "HEAD" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +mean_grad_op_info = AkgRegOp("SimpleMeanGrad") \ + .fusion_type("OPAQUE") \ + .input(0, "HEAD") \ + .output(0, "output") \ + .attr("input_shape", "required", "listInt") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(mean_grad_op_info) def _simple_mean_grad_akg(): """SimpleMeanGrad AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/mul.py b/mindspore/ops/_op_impl/akg/gpu/mul.py index d9e1a0b5d63e2565e4bd54c5832a945d3335d685..db5b1460edfa75339f82ea9d161237bec2a0a430 100644 --- a/mindspore/ops/_op_impl/akg/gpu/mul.py +++ b/mindspore/ops/_op_impl/akg/gpu/mul.py @@ -13,50 +13,19 @@ # limitations under the License. """Mul op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "Mul", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - }, - { - "index": 1, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "y" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +mul_op_info = AkgRegOp("Mul") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .input(1, "y") \ + .output(0, "output") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(mul_op_info) def _mul_akg(): """Mul AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/relu6.py b/mindspore/ops/_op_impl/akg/gpu/relu6.py index 0de0a7e400db847a664b01b5411e0c61662b85a3..31bfebcd8d72471a80cb47491ab92b6158d52b03 100644 --- a/mindspore/ops/_op_impl/akg/gpu/relu6.py +++ b/mindspore/ops/_op_impl/akg/gpu/relu6.py @@ -13,40 +13,18 @@ # limitations under the License. """ReLU6 op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "ReLU6", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +relu_op_info = AkgRegOp("ReLU6") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(relu_op_info) def _relu6_akg(): """ReLU6 AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/relu6_grad.py b/mindspore/ops/_op_impl/akg/gpu/relu6_grad.py index 4d3c5e9a00be9621498010affa249c68d97dbfb0..83d93f30775e3f0d7a3465a678558688efb3981f 100644 --- a/mindspore/ops/_op_impl/akg/gpu/relu6_grad.py +++ b/mindspore/ops/_op_impl/akg/gpu/relu6_grad.py @@ -13,50 +13,19 @@ # limitations under the License. """ReLU6Grad op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "ReLU6Grad", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "y_grad" - }, - { - "index": 1, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +relu_grad_op_info = AkgRegOp("ReLU6Grad") \ + .fusion_type("OPAQUE") \ + .input(0, "y_grad") \ + .input(1, "x") \ + .output(0, "output") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(relu_grad_op_info) def _relu6_grad_akg(): """ReLU6Grad AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/squeeze.py b/mindspore/ops/_op_impl/akg/gpu/squeeze.py index 9e766cdfd7e25a310b780fa5b3b785ac2a8b1de0..378d096d5c419a403a1e902094625a3ed7766bd0 100644 --- a/mindspore/ops/_op_impl/akg/gpu/squeeze.py +++ b/mindspore/ops/_op_impl/akg/gpu/squeeze.py @@ -13,45 +13,19 @@ # limitations under the License. """Squeeze op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "Squeeze", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - { - "name": "axis", - "param_type": "optional", - "type": "listInt" - } - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +squeeze_op_info = AkgRegOp("SqueezeGrad") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .attr("axis", "optional", "listInt") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(squeeze_op_info) def _squeeze_akg(): """Squeeze AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/squeeze_grad.py b/mindspore/ops/_op_impl/akg/gpu/squeeze_grad.py index 7584bd05f92478239eccf282d6164ae73f1c1599..ef397ea0a71e60add3ea25b84adf53aace685dde 100644 --- a/mindspore/ops/_op_impl/akg/gpu/squeeze_grad.py +++ b/mindspore/ops/_op_impl/akg/gpu/squeeze_grad.py @@ -13,50 +13,20 @@ # limitations under the License. """SqueezeGrad op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "SqueezeGrad", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - { - "name": "x_shape", - "param_type": "required", - "type": "listInt" - }, - { - "name": "axis", - "param_type": "optional", - "type": "listInt" - } - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "y_grad" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +squeeze_grad_op_info = AkgRegOp("SqueezeGrad") \ + .fusion_type("OPAQUE") \ + .input(0, "y_grad") \ + .output(0, "output") \ + .attr("x_shape", "required", "listInt") \ + .attr("axis", "optional", "listInt") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(squeeze_grad_op_info) def _squeeze_grad_akg(): """SqueezeGrad AutoDiff register""" return diff --git a/mindspore/ops/_op_impl/akg/gpu/tile.py b/mindspore/ops/_op_impl/akg/gpu/tile.py index f110e9314e0326ea994aabccfefbba96f2e236c0..8c9de0097956e94684014b913c49b89c5644187b 100644 --- a/mindspore/ops/_op_impl/akg/gpu/tile.py +++ b/mindspore/ops/_op_impl/akg/gpu/tile.py @@ -13,45 +13,19 @@ # limitations under the License. """Tile op""" -from mindspore.ops.op_info_register import op_info_register +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType -@op_info_register("""{ - "op_name": "Tile", - "imply_type": "AutoDiff", - "fusion_type": "OPAQUE", - "processor": "cuda", - "attr": [ - { - "name": "multiples", - "param_type": "required", - "type": "listInt" - } - ], - "inputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "x" - } - ], - "outputs": [ - { - "index": 0, - "dtype": [ - "float32", "float16" - ], - "format": [ - "DefaultFormat", "DefaultFormat" - ], - "name": "output" - } - ] -}""") +tile_op_info = AkgRegOp("Tile") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .attr("multiples", "required", "listInt") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default) \ + .get_op_info() + + +@op_info_register(tile_op_info) def _tile_akg(): """Tile AutoDiff register""" return diff --git a/mindspore/ops/op_info_register.py b/mindspore/ops/op_info_register.py index 0750094e18919fe909c11118c1fd4a7858d86793..daf3192d4fc9d868238d5118525564fca697ab00 100644 --- a/mindspore/ops/op_info_register.py +++ b/mindspore/ops/op_info_register.py @@ -205,6 +205,64 @@ class RegOp(): return op_info +class AkgRegOp(RegOp): + """Class for Akg op info register""" + + def __init__(self, op_name): + super(AkgRegOp, self).__init__(op_name) + self.imply_type = "AutoDiff" + self.processor = "cuda" + + def input(self, index=None, name=None, **kwargs): + """ + Register Akg op input information. + + Args: + index (int): Order of the input. Default: None. + name (str): Name of the input. Default: None. + kwargs (dict): Other information for the input. + """ + param_list = [index, name] + key_list = ["index", "name"] + fn_list = [self._is_int, self._is_string] + input_dict = self._check_param(param_list, key_list, fn_list, kwargs) + self.inputs.append(input_dict) + return self + + def output(self, index=None, name=None, **kwargs): + """ + Register Akg op output information. + + Args: + index (int): Order of the output. Default: None. + name (str): Name of the output. Default: None. + kwargs (dict): Other information for the output. + """ + param_list = [index, name] + key_list = ["index", "name"] + fn_list = [self._is_int, self._is_string] + output_dict = self._check_param(param_list, key_list, fn_list, kwargs) + self.outputs.append(output_dict) + return self + + def attr(self, name=None, param_type=None, value_type=None, **kwargs): + """ + Register Akg op attribute information. + + Args: + name (str): Name of the attribute. Default: None. + param_type (str): Param type of the attribute. Default: None. + value_type (str): Value type of the attribute. Default: None. + kwargs (dict): Other information for the attribute. + """ + param_list = [name, param_type, value_type] + key_list = ["name", "param_type", "type"] + fn_list = [self._is_string] + attr_dict = self._check_param(param_list, key_list, fn_list, kwargs) + self.attr_.append(attr_dict) + return self + + class AiCPURegOp(RegOp): """Class for AiCPU op info register"""