forked from OSSInnovation/mindspore
!6333 add padding grad op
Merge pull request !6333 from wuxuejian/padding_grad
This commit is contained in:
commit
fec931c65d
|
@ -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"""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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…
Reference in New Issue