1# Copyright 2020 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15from mindspore.ops import prim_attr_register, PrimitiveWithInfer 16 17 18# sum = input1 + input2 + const_bias 19class CusAdd3(PrimitiveWithInfer): 20 """Custom add3 definition""" 21 22 @prim_attr_register 23 def __init__(self, const_bias=0.0): 24 self.init_prim_io_names(inputs=['input1', 'input2'], outputs=['sum3']) 25 from add3_impl import CusAdd3Impl 26 27 def infer_shape(self, input1, input2): 28 return input1 29 30 def infer_dtype(self, input1, input2): 31 return input1 32