From e893368fae364d50777abcfe47ee35a17b0f147a Mon Sep 17 00:00:00 2001 From: wuxuejian Date: Wed, 16 Sep 2020 15:09:43 +0800 Subject: [PATCH] add padding grad op --- mindspore/ops/_grad/grad_array_ops.py | 13 ++++++++++ mindspore/ops/_op_impl/aicpu/__init__.py | 1 - mindspore/ops/_op_impl/aicpu/unique.py | 31 ------------------------ 3 files changed, 13 insertions(+), 32 deletions(-) delete mode 100644 mindspore/ops/_op_impl/aicpu/unique.py diff --git a/mindspore/ops/_grad/grad_array_ops.py b/mindspore/ops/_grad/grad_array_ops.py index 0caf25f316..a04a18cdbe 100644 --- a/mindspore/ops/_grad/grad_array_ops.py +++ b/mindspore/ops/_grad/grad_array_ops.py @@ -244,6 +244,19 @@ def get_bprop_embedding_lookup(self): return bprop_sparse +@bprop_getters.register(P.Padding) +def get_bprop_padding(self): + """Grad definition for `Padding` operation.""" + + def bprop(x, out, dout): + shp = shape_op(x) + begin = tuple([0 for _ in shp]) + dx = P.Slice()(dout, begin, shp) + return (dx,) + + return bprop + + @bprop_getters.register(P.Transpose) def get_bprop_transpose(self): """Generate bprop for Transpose""" diff --git a/mindspore/ops/_op_impl/aicpu/__init__.py b/mindspore/ops/_op_impl/aicpu/__init__.py index bb63d4bf32..b321db47e0 100644 --- a/mindspore/ops/_op_impl/aicpu/__init__.py +++ b/mindspore/ops/_op_impl/aicpu/__init__.py @@ -13,7 +13,6 @@ # limitations under the License. """aicpu ops""" -from .unique import _unique_aicpu from .init_data_set_queue import _init_data_set_queue_aicpu from .embedding_lookup import _embedding_lookup_aicpu from .padding import _padding_aicpu diff --git a/mindspore/ops/_op_impl/aicpu/unique.py b/mindspore/ops/_op_impl/aicpu/unique.py deleted file mode 100644 index 849e969609..0000000000 --- a/mindspore/ops/_op_impl/aicpu/unique.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2020 Huawei Technologies Co., Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================ - -"""Unique op""" -from mindspore.ops.op_info_register import op_info_register, AiCPURegOp, DataType - -unique_op_info = AiCPURegOp("Unique") \ - .fusion_type("OPAQUE") \ - .input(0, "x", "required") \ - .output(0, "y", "required") \ - .output(1, "idx", "required") \ - .dtype_format(DataType.I32_Default, DataType.I32_Default, DataType.I32_Default) \ - .dtype_format(DataType.I64_Default, DataType.I64_Default, DataType.I64_Default) \ - .get_op_info() - -@op_info_register(unique_op_info) -def _unique_aicpu(): - """Unique AiCPU register""" - return