Browse Source

add padding grad op

tags/v1.0.0
wuxuejian 5 years ago
parent
commit
e893368fae
3 changed files with 13 additions and 32 deletions
  1. +13
    -0
      mindspore/ops/_grad/grad_array_ops.py
  2. +0
    -1
      mindspore/ops/_op_impl/aicpu/__init__.py
  3. +0
    -31
      mindspore/ops/_op_impl/aicpu/unique.py

+ 13
- 0
mindspore/ops/_grad/grad_array_ops.py View File

@@ -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"""


+ 0
- 1
mindspore/ops/_op_impl/aicpu/__init__.py View File

@@ -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


+ 0
- 31
mindspore/ops/_op_impl/aicpu/unique.py View File

@@ -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

Loading…
Cancel
Save