diff --git a/mindspore/ccsrc/frontend/operator/ops.h b/mindspore/ccsrc/frontend/operator/ops.h index 85b0ac474f2a30aa1dd2cd4aa020bbf6baa60d55..80093049caad9c80dfc9d85a813cb6004254a81a 100755 --- a/mindspore/ccsrc/frontend/operator/ops.h +++ b/mindspore/ccsrc/frontend/operator/ops.h @@ -31,160 +31,58 @@ ValuePtr GetPythonOps(const std::string &op_name, const std::string &module_name = "mindspore._extends.parse.standard_method", bool use_signature = false); -// Arithmetic -inline const PrimitivePtr kPrimScalarAdd = std::make_shared("scalar_add"); -inline const PrimitivePtr kPrimScalarSub = std::make_shared("scalar_sub"); -inline const PrimitivePtr kPrimScalarMul = std::make_shared("scalar_mul"); -inline const PrimitivePtr kPrimScalarDiv = std::make_shared("scalar_div"); -inline const PrimitivePtr kPrimScalarFloordiv = std::make_shared("scalar_floordiv"); -inline const PrimitivePtr kPrimScalarMod = std::make_shared("scalar_mod"); -inline const PrimitivePtr kPrimScalarPow = std::make_shared("scalar_pow"); -inline const PrimitivePtr kPrimScalarTrunc = std::make_shared("scalar_trunc"); -inline const PrimitivePtr kPrimScalarFloor = std::make_shared("scalar_floor"); -inline const PrimitivePtr kPrimScalarUadd = std::make_shared("scalar_uadd"); -inline const PrimitivePtr kPrimScalarUsub = std::make_shared("scalar_usub"); -inline const PrimitivePtr kPrimScalarExp = std::make_shared("scalar_exp"); -inline const PrimitivePtr kPrimScalarLog = std::make_shared("scalar_log"); -inline const PrimitivePtr kPrimScalarSin = std::make_shared("scalar_sin"); -inline const PrimitivePtr kPrimScalarCos = std::make_shared("scalar_cos"); -inline const PrimitivePtr kPrimScalarTan = std::make_shared("scalar_tan"); - -// Comparisons -inline const PrimitivePtr kPrimScalarEq = std::make_shared("scalar_eq"); -inline const PrimitivePtr kPrimScalarLt = std::make_shared("scalar_lt"); -inline const PrimitivePtr kPrimScalarGt = std::make_shared("scalar_gt"); -inline const PrimitivePtr kPrimScalarNe = std::make_shared("scalar_ne"); -inline const PrimitivePtr kPrimScalarLe = std::make_shared("scalar_le"); -inline const PrimitivePtr kPrimScalarGe = std::make_shared("scalar_ge"); -inline const PrimitivePtr kPrimBoolNot = std::make_shared("bool_not"); -inline const PrimitivePtr kPrimBoolAnd = std::make_shared("bool_and"); -inline const PrimitivePtr kPrimBoolOr = std::make_shared("bool_or"); -inline const PrimitivePtr kPrimBoolEq = std::make_shared("bool_eq"); -inline const PrimitivePtr kPrimGreater = std::make_shared("Greater"); -inline const PrimitivePtr kPrimGreaterEqual = std::make_shared("GreaterEqual"); -inline const PrimitivePtr kPrimLess = std::make_shared("Less"); -inline const PrimitivePtr kPrimLessEqual = std::make_shared("LessEqual"); -inline const PrimitivePtr kPrimEqual = std::make_shared("Equal"); -inline const PrimitivePtr kPrimNotEqual = std::make_shared("NotEqual"); - +// Primitives only used by frontend; // Type introspection inline const PrimitivePtr kPrimTypeOf = std::make_shared("typeof"); inline const PrimitivePtr kPrimHasType = std::make_shared("hastype"); -inline const PrimitivePtr kPrimDistribute = std::make_shared("distribute"); -inline const PrimitivePtr kPrimDot = std::make_shared("dot"); -inline const PrimitivePtr kPrimIm2Col = std::make_shared("im2col"); -inline const PrimitivePtr kPrimCol2Im = std::make_shared("col2im"); -inline const PrimitivePtr kPrimIm2ColV1 = std::make_shared("im2col_v1"); -inline const PrimitivePtr kPrimCol2ImV1 = std::make_shared("col2im_v1"); - inline const PrimitivePtr kPrimResolve = std::make_shared("resolve"); inline const PrimitivePtr kPrimEmbed = std::make_shared("embed"); inline const PrimitivePtr kPrimRefToEmbed = std::make_shared("RefToEmbed"); inline const PrimitivePtr kPrimCreateInstance = std::make_shared("create_instance"); -inline const PrimitivePtr kPrimLabelGoto = std::make_shared("LabelGoto"); -inline const PrimitivePtr kPrimLabelSwitch = std::make_shared("LabelSwitch"); -inline const PrimitivePtr kPrimLabelSet = std::make_shared("LabelSet"); +// Other miscellaneous +inline const PrimitivePtr kPrimEnvSetItem = std::make_shared("env_setitem"); +inline const PrimitivePtr kPrimEnvGetItem = std::make_shared("env_getitem"); +inline const PrimitivePtr kPrimEnvAdd = std::make_shared("env_add"); +inline const PrimitivePtr kPrimMakeRefKey = std::make_shared("MakeRefKey"); +inline const PrimitivePtr kPrimGetRefKey = std::make_shared("get_ref_key"); +inline const PrimitivePtr kPrimGetRefValue = std::make_shared("get_ref_value"); +inline const PrimitivePtr kPrimGetRefOrigin = std::make_shared("get_ref_origin"); +inline const PrimitivePtr kPrimInsertGradientOf = std::make_shared("InsertGradientOf"); +inline const PrimitivePtr kPrimCheckBprop = std::make_shared("CheckBprop"); +inline const PrimitivePtr kPrimMakeRef = std::make_shared("make_ref"); +inline const PrimitivePtr kPrimMixedPrecisionCast = std::make_shared("mixed_precision_cast"); +inline const PrimitivePtr kPrimMakeRecord = std::make_shared("make_record"); + +// Structures +inline const PrimitivePtr kPrimMakeList = std::make_shared("make_list"); +inline const PrimitivePtr kPrimMakeKeywordArg = std::make_shared("make_keyword_arg"); +inline const PrimitivePtr kPrimListGetItem = std::make_shared("list_getitem"); +inline const PrimitivePtr kPrimListSetItem = std::make_shared("list_setitem"); +inline const PrimitivePtr kPrimDictGetItem = std::make_shared("dict_getitem"); +inline const PrimitivePtr kPrimDictSetItem = std::make_shared("dict_setitem"); +inline const PrimitivePtr kPrimListAppend = std::make_shared("list_append"); +inline const PrimitivePtr kPrimListLen = std::make_shared("list_len"); + +inline const PrimitivePtr kPrimListMap = std::make_shared("list_map"); +inline const PrimitivePtr kPrimListReduce = std::make_shared("list_reduce"); +inline const PrimitivePtr kPrimTupleReversed = std::make_shared("tuple_reversed"); +inline const PrimitivePtr kPrimReducedShape = std::make_shared("reduced_shape"); +inline const PrimitivePtr kPrimTupleDiv = std::make_shared("tuple_div"); +inline const PrimitivePtr kPrimTupleToArray = std::make_shared("tuple_to_array"); +inline const PrimitivePtr kPrimShapeMul = std::make_shared("shape_mul"); +inline const PrimitivePtr kPrimTupleEqual = std::make_shared("tuple_equal"); +inline const PrimitivePtr kPrimListEqual = std::make_shared("list_equal"); +inline const PrimitivePtr kPrimMakeRange = std::make_shared("make_range"); +inline const PrimitivePtr kPrimStopGradient = std::make_shared("stop_gradient"); +inline const PrimitivePtr kPrimStringEqual = std::make_shared("string_equal"); +inline const PrimitivePtr kPrimStringConcat = std::make_shared("string_concat"); +inline const PrimitivePtr kPrimDictLen = std::make_shared("dict_len"); -// Arrays -inline const PrimitivePtr kPrimScalarToArray = std::make_shared("scalar_to_array"); -inline const PrimitivePtr kPrimArrayToScalar = std::make_shared("array_to_scalar"); -inline const PrimitivePtr kPrimBroadcastShape = std::make_shared("broadcast_shape"); -inline const PrimitivePtr kPrimArrayMap = std::make_shared("array_map"); -inline const PrimitivePtr kPrimArrayReduce = std::make_shared("array_reduce"); -inline const PrimitivePtr kPrimCast = std::make_shared("Cast"); -inline const PrimitivePtr kPrimConcat = std::make_shared("Concat"); -inline const PrimitivePtr kPrimSqueeze = std::make_shared("Squeeze"); -inline const PrimitivePtr kPrimTranspose = std::make_shared("Transpose"); -inline const PrimitivePtr kPrimGatherV2 = std::make_shared("GatherV2"); -inline const PrimitivePtr kPrimEmbeddingLookup = std::make_shared("EmbeddingLookup"); -inline const PrimitivePtr kPrimEmbeddingLookupCommGrad = std::make_shared("EmbeddingLookupCommGrad"); -inline const PrimitivePtr kPrimSize = std::make_shared("Size"); -inline const PrimitivePtr kPrimArgMax = std::make_shared("Argmax"); -inline const PrimitivePtr kPrimPack = std::make_shared("Pack"); -inline const PrimitivePtr kPrimUnsortedSegmentSum = std::make_shared("UnsortedSegmentSum"); -inline const PrimitivePtr kPrimUnsortedSegmentMin = std::make_shared("UnsortedSegmentMin"); -inline const PrimitivePtr kPrimConcatOffset = std::make_shared("ConcatOffset"); -inline const PrimitivePtr kPrimReshape = std::make_shared("Reshape"); -inline const PrimitivePtr kPrimTile = std::make_shared("Tile"); -inline const PrimitivePtr kPrimAddN = std::make_shared("AddN"); -inline const PrimitivePtr KPrimTransData = std::make_shared("TransData"); -inline const PrimitivePtr kPrimNMSWithMask = std::make_shared("NMSWithMask"); -inline const PrimitivePtr kPrimPad = std::make_shared("Pad"); -inline const PrimitivePtr kPrimArgMaxWithValue = std::make_shared("ArgMaxWithValue"); -inline const PrimitivePtr kPrimUnique = std::make_shared("Unique"); -inline const PrimitivePtr kPrimUniqueGrad = std::make_shared("UniqueGrad"); - -// NN -inline const PrimitivePtr kPrimFlatten = std::make_shared("Flatten"); -inline const PrimitivePtr kPrimSoftmax = std::make_shared("Softmax"); -inline const PrimitivePtr kPrimLogSoftmax = std::make_shared("LogSoftmax"); -inline const PrimitivePtr kPrimLogSoftmaxGrad = std::make_shared("LogSoftmaxGrad"); -inline const PrimitivePtr kPrimTanh = std::make_shared("Tanh"); -inline const PrimitivePtr kPrimTanhGrad = std::make_shared("TanhGrad"); -inline const PrimitivePtr kPrimPooling = std::make_shared("Pooling"); -inline const PrimitivePtr kPrimPoolingGrad = std::make_shared("PoolingGrad"); -inline const PrimitivePtr kPrimMaxPool = std::make_shared("MaxPool"); -inline const PrimitivePtr kPrimMaxPoolGrad = std::make_shared("MaxPoolGrad"); -inline const PrimitivePtr kPrimApplyCenteredRMSProp = std::make_shared("ApplyCenteredRMSProp"); -inline const PrimitivePtr kPrimAvgPoolGrad = std::make_shared("AvgPoolGrad"); -inline const PrimitivePtr kPrimAvgPoolGradVm = std::make_shared("AvgPoolGradVm"); -inline const PrimitivePtr kPrimFusedBatchNorm = std::make_shared("FusedBatchNorm"); -inline const PrimitivePtr kPrimConv2D = std::make_shared("Conv2D"); -inline const PrimitivePtr kPrimFusedBatchNormGrad = std::make_shared("FusedBatchNormGrad"); -inline const PrimitivePtr kPrimBatchNorm = std::make_shared("BatchNorm"); -inline const PrimitivePtr kPrimBatchNormGrad = std::make_shared("BatchNormGrad"); -inline const PrimitivePtr kPrimReluGrad = std::make_shared("ReluGrad"); -inline const PrimitivePtr kPrimConv2DBackpropInput = std::make_shared("Conv2DBackpropInput"); -inline const PrimitivePtr kPrimConv2DBackpropFilter = std::make_shared("Conv2DBackpropFilter"); -inline const PrimitivePtr kPrimDepthwiseConv2dNative = std::make_shared("DepthwiseConv2dNative"); -inline const PrimitivePtr kPrimDepthwiseConv2dNativeBackpropFilter = - std::make_shared("DepthwiseConv2dNativeBackpropFilter"); -inline const PrimitivePtr kPrimDepthwiseConv2dNativeBackpropInput = - std::make_shared("DepthwiseConv2dNativeBackpropInput"); -inline const PrimitivePtr kPrimBiasAddGrad = std::make_shared("BiasAddGrad"); -inline const PrimitivePtr kPrimSoftmaxCrossEntropyWithLogits = - std::make_shared("SoftmaxCrossEntropyWithLogits"); -inline const PrimitivePtr kPrimSparseSoftmaxCrossEntropyWithLogits = - std::make_shared("SparseSoftmaxCrossEntropyWithLogits"); -inline const PrimitivePtr kPrimMomentum = std::make_shared("Momentum"); -inline const PrimitivePtr kPrimApplyMomentum = std::make_shared("ApplyMomentum"); -inline const PrimitivePtr kPrimLayerNorm = std::make_shared("LayerNorm"); -inline const PrimitivePtr kPrimLayerNormGrad = std::make_shared("LayerNormGrad"); -inline const PrimitivePtr kPrimLayerNormXBackprop = std::make_shared("LayerNormXBackprop"); -inline const PrimitivePtr kPrimLayerNormBetaGammaBackprop = std::make_shared("LayerNormBetaGammaBackprop"); -inline const PrimitivePtr kPrimDropoutGenMask = std::make_shared("DropoutGenMask"); -inline const PrimitivePtr kPrimDropoutDoMask = std::make_shared("DropoutDoMask"); -inline const PrimitivePtr kPrimOneHot = std::make_shared("OneHot"); -inline const PrimitivePtr kPrimGelu = std::make_shared("Gelu"); -inline const PrimitivePtr kPrimGeluGrad = std::make_shared("GeluGrad"); -inline const PrimitivePtr kPrimRelu = std::make_shared("ReLU"); -inline const PrimitivePtr kPrimReluV2 = std::make_shared("ReLUV2"); -inline const PrimitivePtr kPrimZerosLike = std::make_shared("ZerosLike"); inline const PrimitivePtr kPrimFakeBprop = std::make_shared("fake_bprop"); -inline const PrimitivePtr kPrimBpropCut = std::make_shared("bprop_cut"); -inline const PrimitivePtr kPrimFakeQuantPerLayer = std::make_shared("FakeQuantPerLayer"); -inline const PrimitivePtr kPrimFakeQuantPerChannel = std::make_shared("FakeQuantPerChannel"); -inline const PrimitivePtr kPrimApplyRMSProp = std::make_shared("ApplyRMSProp"); - -// Comm ops -inline const PrimitivePtr kPrimMirror = std::make_shared("_MirrorOperator"); -inline const PrimitivePtr kPrimVirtualDiv = std::make_shared("_VirtualDiv"); -inline const PrimitivePtr kPrimVirtualDataset = std::make_shared("_VirtualDataset"); -inline const PrimitivePtr kPrimAllReduce = std::make_shared("AllReduce"); - -// RowTensor -inline const PrimitivePtr kPrimMakeRowTensor = std::make_shared("MakeRowTensor"); -inline const PrimitivePtr kPrimRowTensorGetValues = std::make_shared("RowTensorGetValues"); -inline const PrimitivePtr kPrimRowTensorGetIndices = std::make_shared("RowTensorGetIndices"); -inline const PrimitivePtr kPrimRowTensorGetDenseShape = std::make_shared("RowTensorGetDenseShape"); -// SparseTensor -inline const PrimitivePtr kPrimMakeSparseTensor = std::make_shared("MakeSparseTensor"); -inline const PrimitivePtr kPrimSparseTensorGetValues = std::make_shared("SparseTensorGetValues"); -inline const PrimitivePtr kPrimSparseTensorGetIndices = std::make_shared("SparseTensorGetIndices"); -inline const PrimitivePtr kPrimSparseTensorGetDenseShape = std::make_shared("SparseTensorGetDenseShape"); +inline const PrimitivePtr kPrimBroadcastGradientArgs = std::make_shared("BroadcastGradientArgs"); class UnpackGraphPrimitive : public Primitive { public: diff --git a/mindspore/core/base/core_ops.h b/mindspore/core/base/core_ops.h index 76bdb4231ede879e233f31793ed409bd6f926de7..ddd490c9d47616113956d9c8bddb9c2cfca68193 100755 --- a/mindspore/core/base/core_ops.h +++ b/mindspore/core/base/core_ops.h @@ -25,6 +25,152 @@ namespace mindspore { namespace prim { +// Here list all primitives used in backend or some special primitives used by core. +// Arithmetic +inline const PrimitivePtr kPrimScalarAdd = std::make_shared("scalar_add"); +inline const PrimitivePtr kPrimScalarSub = std::make_shared("scalar_sub"); +inline const PrimitivePtr kPrimScalarMul = std::make_shared("scalar_mul"); +inline const PrimitivePtr kPrimScalarDiv = std::make_shared("scalar_div"); +inline const PrimitivePtr kPrimScalarFloordiv = std::make_shared("scalar_floordiv"); +inline const PrimitivePtr kPrimScalarMod = std::make_shared("scalar_mod"); +inline const PrimitivePtr kPrimScalarPow = std::make_shared("scalar_pow"); +inline const PrimitivePtr kPrimScalarTrunc = std::make_shared("scalar_trunc"); +inline const PrimitivePtr kPrimScalarFloor = std::make_shared("scalar_floor"); +inline const PrimitivePtr kPrimScalarUadd = std::make_shared("scalar_uadd"); +inline const PrimitivePtr kPrimScalarUsub = std::make_shared("scalar_usub"); +inline const PrimitivePtr kPrimScalarExp = std::make_shared("scalar_exp"); +inline const PrimitivePtr kPrimScalarLog = std::make_shared("scalar_log"); +inline const PrimitivePtr kPrimScalarSin = std::make_shared("scalar_sin"); +inline const PrimitivePtr kPrimScalarCos = std::make_shared("scalar_cos"); +inline const PrimitivePtr kPrimScalarTan = std::make_shared("scalar_tan"); + +// Comparisons +inline const PrimitivePtr kPrimScalarEq = std::make_shared("scalar_eq"); +inline const PrimitivePtr kPrimScalarLt = std::make_shared("scalar_lt"); +inline const PrimitivePtr kPrimScalarGt = std::make_shared("scalar_gt"); +inline const PrimitivePtr kPrimScalarNe = std::make_shared("scalar_ne"); +inline const PrimitivePtr kPrimScalarLe = std::make_shared("scalar_le"); +inline const PrimitivePtr kPrimScalarGe = std::make_shared("scalar_ge"); +inline const PrimitivePtr kPrimBoolNot = std::make_shared("bool_not"); +inline const PrimitivePtr kPrimBoolAnd = std::make_shared("bool_and"); +inline const PrimitivePtr kPrimBoolOr = std::make_shared("bool_or"); +inline const PrimitivePtr kPrimBoolEq = std::make_shared("bool_eq"); +inline const PrimitivePtr kPrimGreater = std::make_shared("Greater"); +inline const PrimitivePtr kPrimGreaterEqual = std::make_shared("GreaterEqual"); +inline const PrimitivePtr kPrimLess = std::make_shared("Less"); +inline const PrimitivePtr kPrimLessEqual = std::make_shared("LessEqual"); +inline const PrimitivePtr kPrimEqual = std::make_shared("Equal"); +inline const PrimitivePtr kPrimNotEqual = std::make_shared("NotEqual"); + +inline const PrimitivePtr kPrimDistribute = std::make_shared("distribute"); +inline const PrimitivePtr kPrimDot = std::make_shared("dot"); +inline const PrimitivePtr kPrimIm2Col = std::make_shared("im2col"); +inline const PrimitivePtr kPrimCol2Im = std::make_shared("col2im"); +inline const PrimitivePtr kPrimIm2ColV1 = std::make_shared("im2col_v1"); +inline const PrimitivePtr kPrimCol2ImV1 = std::make_shared("col2im_v1"); + +inline const PrimitivePtr kPrimLabelGoto = std::make_shared("LabelGoto"); +inline const PrimitivePtr kPrimLabelSwitch = std::make_shared("LabelSwitch"); +inline const PrimitivePtr kPrimLabelSet = std::make_shared("LabelSet"); + +// Arrays +inline const PrimitivePtr kPrimScalarToArray = std::make_shared("scalar_to_array"); +inline const PrimitivePtr kPrimArrayToScalar = std::make_shared("array_to_scalar"); +inline const PrimitivePtr kPrimBroadcastShape = std::make_shared("broadcast_shape"); +inline const PrimitivePtr kPrimArrayMap = std::make_shared("array_map"); +inline const PrimitivePtr kPrimArrayReduce = std::make_shared("array_reduce"); +inline const PrimitivePtr kPrimCast = std::make_shared("Cast"); +inline const PrimitivePtr kPrimConcat = std::make_shared("Concat"); +inline const PrimitivePtr kPrimSqueeze = std::make_shared("Squeeze"); +inline const PrimitivePtr kPrimTranspose = std::make_shared("Transpose"); +inline const PrimitivePtr kPrimGatherV2 = std::make_shared("GatherV2"); +inline const PrimitivePtr kPrimEmbeddingLookup = std::make_shared("EmbeddingLookup"); +inline const PrimitivePtr kPrimEmbeddingLookupCommGrad = std::make_shared("EmbeddingLookupCommGrad"); +inline const PrimitivePtr kPrimSize = std::make_shared("Size"); +inline const PrimitivePtr kPrimArgMax = std::make_shared("Argmax"); +inline const PrimitivePtr kPrimPack = std::make_shared("Pack"); +inline const PrimitivePtr kPrimUnsortedSegmentSum = std::make_shared("UnsortedSegmentSum"); +inline const PrimitivePtr kPrimUnsortedSegmentMin = std::make_shared("UnsortedSegmentMin"); +inline const PrimitivePtr kPrimConcatOffset = std::make_shared("ConcatOffset"); +inline const PrimitivePtr kPrimReshape = std::make_shared("Reshape"); +inline const PrimitivePtr kPrimTile = std::make_shared("Tile"); +inline const PrimitivePtr kPrimAddN = std::make_shared("AddN"); +inline const PrimitivePtr KPrimTransData = std::make_shared("TransData"); +inline const PrimitivePtr kPrimNMSWithMask = std::make_shared("NMSWithMask"); +inline const PrimitivePtr kPrimPad = std::make_shared("Pad"); +inline const PrimitivePtr kPrimArgMaxWithValue = std::make_shared("ArgMaxWithValue"); +inline const PrimitivePtr kPrimUnique = std::make_shared("Unique"); +inline const PrimitivePtr kPrimUniqueGrad = std::make_shared("UniqueGrad"); + +// NN +inline const PrimitivePtr kPrimFlatten = std::make_shared("Flatten"); +inline const PrimitivePtr kPrimSoftmax = std::make_shared("Softmax"); +inline const PrimitivePtr kPrimLogSoftmax = std::make_shared("LogSoftmax"); +inline const PrimitivePtr kPrimLogSoftmaxGrad = std::make_shared("LogSoftmaxGrad"); +inline const PrimitivePtr kPrimTanh = std::make_shared("Tanh"); +inline const PrimitivePtr kPrimTanhGrad = std::make_shared("TanhGrad"); +inline const PrimitivePtr kPrimPooling = std::make_shared("Pooling"); +inline const PrimitivePtr kPrimPoolingGrad = std::make_shared("PoolingGrad"); +inline const PrimitivePtr kPrimMaxPool = std::make_shared("MaxPool"); +inline const PrimitivePtr kPrimMaxPoolGrad = std::make_shared("MaxPoolGrad"); +inline const PrimitivePtr kPrimApplyCenteredRMSProp = std::make_shared("ApplyCenteredRMSProp"); +inline const PrimitivePtr kPrimAvgPoolGrad = std::make_shared("AvgPoolGrad"); +inline const PrimitivePtr kPrimAvgPoolGradVm = std::make_shared("AvgPoolGradVm"); +inline const PrimitivePtr kPrimFusedBatchNorm = std::make_shared("FusedBatchNorm"); +inline const PrimitivePtr kPrimConv2D = std::make_shared("Conv2D"); +inline const PrimitivePtr kPrimFusedBatchNormGrad = std::make_shared("FusedBatchNormGrad"); +inline const PrimitivePtr kPrimBatchNorm = std::make_shared("BatchNorm"); +inline const PrimitivePtr kPrimBatchNormGrad = std::make_shared("BatchNormGrad"); +inline const PrimitivePtr kPrimReluGrad = std::make_shared("ReluGrad"); +inline const PrimitivePtr kPrimConv2DBackpropInput = std::make_shared("Conv2DBackpropInput"); +inline const PrimitivePtr kPrimConv2DBackpropFilter = std::make_shared("Conv2DBackpropFilter"); +inline const PrimitivePtr kPrimDepthwiseConv2dNative = std::make_shared("DepthwiseConv2dNative"); +inline const PrimitivePtr kPrimDepthwiseConv2dNativeBackpropFilter = + std::make_shared("DepthwiseConv2dNativeBackpropFilter"); +inline const PrimitivePtr kPrimDepthwiseConv2dNativeBackpropInput = + std::make_shared("DepthwiseConv2dNativeBackpropInput"); +inline const PrimitivePtr kPrimBiasAddGrad = std::make_shared("BiasAddGrad"); +inline const PrimitivePtr kPrimSoftmaxCrossEntropyWithLogits = + std::make_shared("SoftmaxCrossEntropyWithLogits"); +inline const PrimitivePtr kPrimSparseSoftmaxCrossEntropyWithLogits = + std::make_shared("SparseSoftmaxCrossEntropyWithLogits"); +inline const PrimitivePtr kPrimMomentum = std::make_shared("Momentum"); +inline const PrimitivePtr kPrimApplyMomentum = std::make_shared("ApplyMomentum"); +inline const PrimitivePtr kPrimLayerNorm = std::make_shared("LayerNorm"); +inline const PrimitivePtr kPrimLayerNormGrad = std::make_shared("LayerNormGrad"); +inline const PrimitivePtr kPrimLayerNormXBackprop = std::make_shared("LayerNormXBackprop"); +inline const PrimitivePtr kPrimLayerNormBetaGammaBackprop = std::make_shared("LayerNormBetaGammaBackprop"); +inline const PrimitivePtr kPrimDropoutGenMask = std::make_shared("DropoutGenMask"); +inline const PrimitivePtr kPrimDropoutDoMask = std::make_shared("DropoutDoMask"); +inline const PrimitivePtr kPrimOneHot = std::make_shared("OneHot"); +inline const PrimitivePtr kPrimGelu = std::make_shared("Gelu"); +inline const PrimitivePtr kPrimGeluGrad = std::make_shared("GeluGrad"); +inline const PrimitivePtr kPrimRelu = std::make_shared("ReLU"); +inline const PrimitivePtr kPrimReluV2 = std::make_shared("ReLUV2"); +inline const PrimitivePtr kPrimZerosLike = std::make_shared("ZerosLike"); +inline const PrimitivePtr kPrimBpropCut = std::make_shared("bprop_cut"); +inline const PrimitivePtr kPrimFakeQuantPerLayer = std::make_shared("FakeQuantPerLayer"); +inline const PrimitivePtr kPrimFakeQuantPerChannel = std::make_shared("FakeQuantPerChannel"); +inline const PrimitivePtr kPrimApplyRMSProp = std::make_shared("ApplyRMSProp"); + +// Comm ops +inline const PrimitivePtr kPrimMirror = std::make_shared("_MirrorOperator"); +inline const PrimitivePtr kPrimVirtualDiv = std::make_shared("_VirtualDiv"); +inline const PrimitivePtr kPrimVirtualDataset = std::make_shared("_VirtualDataset"); +inline const PrimitivePtr kPrimAllReduce = std::make_shared("AllReduce"); + +// RowTensor +inline const PrimitivePtr kPrimMakeRowTensor = std::make_shared("MakeRowTensor"); +inline const PrimitivePtr kPrimRowTensorGetValues = std::make_shared("RowTensorGetValues"); +inline const PrimitivePtr kPrimRowTensorGetIndices = std::make_shared("RowTensorGetIndices"); +inline const PrimitivePtr kPrimRowTensorGetDenseShape = std::make_shared("RowTensorGetDenseShape"); + +// SparseTensor +inline const PrimitivePtr kPrimMakeSparseTensor = std::make_shared("MakeSparseTensor"); +inline const PrimitivePtr kPrimSparseTensorGetValues = std::make_shared("SparseTensorGetValues"); +inline const PrimitivePtr kPrimSparseTensorGetIndices = std::make_shared("SparseTensorGetIndices"); +inline const PrimitivePtr kPrimSparseTensorGetDenseShape = std::make_shared("SparseTensorGetDenseShape"); + // Maths inline const PrimitivePtr kPrimTensorAdd = std::make_shared("TensorAdd"); inline const PrimitivePtr kPrimMatMul = std::make_shared("MatMul"); @@ -64,44 +210,18 @@ inline const PrimitivePtr kPrimAssignSub = std::make_shared("AssignSu inline const PrimitivePtr kPrimSelect = std::make_shared("Select"); inline const PrimitivePtr kPrimCall = std::make_shared("call"); -// Structures -inline const PrimitivePtr kPrimStringEqual = std::make_shared("string_equal"); -inline const PrimitivePtr kPrimStringConcat = std::make_shared("string_concat"); inline const PrimitivePtr kPrimMakeTuple = std::make_shared("make_tuple"); -inline const PrimitivePtr kPrimMakeDict = std::make_shared("make_dict"); -inline const PrimitivePtr kPrimMakeList = std::make_shared("make_list"); -inline const PrimitivePtr kPrimMakeKeywordArg = std::make_shared("make_keyword_arg"); inline const PrimitivePtr kPrimMakeSlice = std::make_shared("make_slice"); -inline const PrimitivePtr kPrimMakeRecord = std::make_shared("make_record"); inline const PrimitivePtr kPrimTupleGetItem = std::make_shared("tuple_getitem"); -inline const PrimitivePtr kPrimListGetItem = std::make_shared("list_getitem"); inline const PrimitivePtr kPrimArrayGetItem = std::make_shared("array_getitem"); inline const PrimitivePtr kPrimTupleSetItem = std::make_shared("tuple_setitem"); -inline const PrimitivePtr kPrimListSetItem = std::make_shared("list_setitem"); inline const PrimitivePtr kPrimArraySetItem = std::make_shared("array_setitem"); -inline const PrimitivePtr kPrimDictGetItem = std::make_shared("dict_getitem"); -inline const PrimitivePtr kPrimDictSetItem = std::make_shared("dict_setitem"); -inline const PrimitivePtr kPrimListAppend = std::make_shared("list_append"); inline const PrimitivePtr kPrimGetAttr = std::make_shared("getattr"); inline const PrimitivePtr kPrimTupleLen = std::make_shared("tuple_len"); -inline const PrimitivePtr kPrimDictLen = std::make_shared("dict_len"); -inline const PrimitivePtr kPrimListLen = std::make_shared("list_len"); inline const PrimitivePtr kPrimArrayLen = std::make_shared("array_len"); -inline const PrimitivePtr kPrimListMap = std::make_shared("list_map"); -inline const PrimitivePtr kPrimListReduce = std::make_shared("list_reduce"); -inline const PrimitivePtr kPrimTupleReversed = std::make_shared("tuple_reversed"); inline const PrimitivePtr kPrimTileShape = std::make_shared("tile_shape"); -inline const PrimitivePtr kPrimReducedShape = std::make_shared("reduced_shape"); -inline const PrimitivePtr kPrimTupleDiv = std::make_shared("tuple_div"); -inline const PrimitivePtr kPrimTupleToArray = std::make_shared("tuple_to_array"); -inline const PrimitivePtr kPrimShapeMul = std::make_shared("shape_mul"); inline const PrimitivePtr kPrimGenerateShapeIndex = std::make_shared("generate_shape_index"); inline const PrimitivePtr kPrimGenerateInverseIndex = std::make_shared("generate_inverse_index"); -inline const PrimitivePtr kPrimTupleEqual = std::make_shared("tuple_equal"); -inline const PrimitivePtr kPrimListEqual = std::make_shared("list_equal"); -inline const PrimitivePtr kPrimMakeRange = std::make_shared("make_range"); -inline const PrimitivePtr kPrimStopGradient = std::make_shared("stop_gradient"); -inline const PrimitivePtr kPrimExtractKeywordArg = std::make_shared("extract_keyword_arg"); // Debug ops inline const PrimitivePtr kPrimScalarSummary = std::make_shared("ScalarSummary"); @@ -111,34 +231,29 @@ inline const PrimitivePtr kPrimHistogramSummary = std::make_shared("H inline const PrimitivePtr kPrimDebug = std::make_shared("Debug"); // Other miscellaneous -inline const PrimitivePtr kPrimJ = std::make_shared("J"); inline const PrimitivePtr kPrimDepend = std::make_shared("Depend"); inline const PrimitivePtr kPrimPartial = std::make_shared("Partial"); inline const PrimitivePtr kPrimIdentity = std::make_shared("identity"); -inline const PrimitivePtr kPrimEnvSetItem = std::make_shared("env_setitem"); -inline const PrimitivePtr kPrimEnvGetItem = std::make_shared("env_getitem"); -inline const PrimitivePtr kPrimEnvAdd = std::make_shared("env_add"); -inline const PrimitivePtr kPrimMakeRefKey = std::make_shared("MakeRefKey"); -inline const PrimitivePtr kPrimGetRefKey = std::make_shared("get_ref_key"); -inline const PrimitivePtr kPrimGetRefValue = std::make_shared("get_ref_value"); -inline const PrimitivePtr kPrimInsertGradientOf = std::make_shared("InsertGradientOf"); inline const PrimitivePtr kPrimHookBackward = std::make_shared("HookBackward"); inline const PrimitivePtr kPrimPrintShapeType = std::make_shared("PrintShapeType"); inline const PrimitivePtr kPrimSameTypeShape = std::make_shared("SameTypeShape"); -inline const PrimitivePtr kPrimCheckBprop = std::make_shared("CheckBprop"); inline const PrimitivePtr kPrimPrint = std::make_shared("Print"); -inline const PrimitivePtr kPrimMakeRef = std::make_shared("make_ref"); -inline const PrimitivePtr kPrimStateSetItem = std::make_shared("state_setitem"); -inline const PrimitivePtr kPrimBroadcastGradientArgs = std::make_shared("BroadcastGradientArgs"); inline const PrimitivePtr kPrimControlDepend = std::make_shared("ControlDepend"); inline const PrimitivePtr kPrimIs_ = std::make_shared("is_"); inline const PrimitivePtr kPrimIsNot = std::make_shared("is_not"); inline const PrimitivePtr kPrimInDict = std::make_shared("in_dict"); inline const PrimitivePtr kPrimNotInDict = std::make_shared("not_in_dict"); -inline const PrimitivePtr kPrimMixedPrecisionCast = std::make_shared("mixed_precision_cast"); inline const PrimitivePtr kPrimIsConsant = std::make_shared("is_constant"); inline const PrimitivePtr kPrimEquivFormat = std::make_shared("EquivFormat"); +// Other primitve not used by backend but used in core; +inline const PrimitivePtr kPrimStateSetItem = std::make_shared("state_setitem"); +inline const PrimitivePtr kPrimJ = std::make_shared("J"); + +// Used to build graph which have keyword arguments +inline const PrimitivePtr kPrimExtractKeywordArg = std::make_shared("extract_keyword_arg"); +inline const PrimitivePtr kPrimMakeDict = std::make_shared("make_dict"); + class DoSignaturePrimitive : public Primitive { public: explicit DoSignaturePrimitive(const std::string &name, const ValuePtr &function)