• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CORE_BASE_CORE_OPS_H_
18 #define MINDSPORE_CORE_BASE_CORE_OPS_H_
19 
20 #include <iostream>
21 #include <string>
22 #include <memory>
23 #include <unordered_map>
24 #include "ir/anf.h"
25 #include "ir/primitive.h"
26 #include "utils/flags.h"
27 
28 namespace mindspore {
29 namespace prim {
30 inline const ValuePtr kValueOne = std::make_shared<Int64Imm>(1);
31 inline const std::unordered_map<std::string, ValuePtr> kSideEffectPropagate = {
32   {mindspore::GRAPH_FLAG_SIDE_EFFECT_PROPAGATE, kValueOne},
33 };
34 
35 constexpr auto kGetNext = "GetNext";
36 constexpr auto kGather = "Gather";
37 constexpr auto kCdist = "Cdist";
38 constexpr auto kCdistGrad = "CdistGrad";
39 // Arithmetic
40 constexpr auto kScalarAdd = "ScalarAdd";
41 constexpr auto kScalarSub = "ScalarSub";
42 constexpr auto kScalarMul = "ScalarMul";
43 constexpr auto kScalarDiv = "ScalarDiv";
44 constexpr auto kScalarFloordiv = "ScalarFloordiv";
45 constexpr auto kScalarMod = "ScalarMod";
46 constexpr auto kScalarPow = "ScalarPow";
47 constexpr auto kScalarTrunc = "ScalarTrunc";
48 constexpr auto kScalarFloor = "ScalarFloor";
49 constexpr auto kScalarUadd = "ScalarUadd";
50 constexpr auto kScalarUsub = "ScalarUsub";
51 constexpr auto kExp = "Exp";
52 constexpr auto kEqual = "Equal";
53 constexpr auto kNotEqual = "NotEqual";
54 constexpr auto kNeg = "Neg";
55 constexpr auto kSub = "Sub";
56 constexpr auto kMul = "Mul";
57 constexpr auto kRealDiv = "RealDiv";
58 constexpr auto kReciprocal = "Reciprocal";
59 constexpr auto kLog = "Log";
60 constexpr auto kSelect = "Select";
61 constexpr auto kAdd = "Add";
62 constexpr auto kBiasAdd = "BiasAdd";
63 constexpr auto kTile = "Tile";
64 constexpr auto kBiasAddGrad = "BiasAddGrad";
65 constexpr auto kCos = "Cos";
66 constexpr auto kAbs = "Abs";
67 constexpr auto kSquare = "Square";
68 
69 // Arrays
70 constexpr auto kDynamicShape = "DynamicShape";
71 constexpr auto kStack = "Stack";
72 constexpr auto kUnstack = "Unstack";
73 constexpr auto kTupleGetItem = "TupleGetItem";
74 constexpr auto kGeLU = "GeLU";
75 constexpr auto kGLU = "GLU";
76 constexpr auto kReLU = "ReLU";
77 constexpr auto kReLU6 = "ReLU6";
78 constexpr auto kReLUV2 = "ReLUV2";
79 constexpr auto kReLUGrad = "ReluGrad";
80 constexpr auto kReLUGradV2 = "ReluGradV2";
81 constexpr auto kGeLUGrad = "GeLUGrad";
82 constexpr auto kFastGeLU = "FastGeLU";
83 constexpr auto kFastGeLUGrad = "FastGeLUGrad";
84 constexpr auto kStridedSlice = "StridedSlice";
85 constexpr auto kZerosLike = "ZerosLike";
86 constexpr auto kOnes = "Ones";
87 constexpr auto kOnesLike = "OnesLike";
88 constexpr auto kDiag = "Diag";
89 constexpr auto kDiagPart = "DiagPart";
90 constexpr auto kDynamicBroadcastGradientArgs = "DynamicBroadcastGradientArgs";
91 constexpr auto kTranspose = "Transpose";
92 constexpr auto kSplitV = "SplitV";
93 
94 // NN
95 constexpr auto kCTCLoss = "CTCLoss";
96 constexpr auto kLayerNorm = "LayerNorm";
97 constexpr auto kLayerNormGrad = "LayerNormGrad";
98 constexpr auto kDropoutGenMask = "DropoutGenMask";
99 constexpr auto kDropoutDoMask = "DropoutDoMask";
100 constexpr auto kDropout = "Dropout";
101 constexpr auto kDropoutGrad = "DropoutGrad";
102 constexpr auto kConv2DTranspose = "Conv2DTranspose";
103 constexpr auto kRoll = "Roll";
104 
105 // Here list all primitives used in backend or some special primitives used by core.
106 // GetNext
107 inline const PrimitivePtr kPrimGetNext = std::make_shared<Primitive>(kGetNext);
108 
109 // Arithmetic
110 inline const PrimitivePtr kPrimScalarAdd = std::make_shared<Primitive>(kScalarAdd);
111 inline const PrimitivePtr kPrimScalarSub = std::make_shared<Primitive>(kScalarSub);
112 inline const PrimitivePtr kPrimScalarMul = std::make_shared<Primitive>(kScalarMul);
113 inline const PrimitivePtr kPrimScalarDiv = std::make_shared<Primitive>(kScalarDiv);
114 inline const PrimitivePtr kPrimScalarFloordiv = std::make_shared<Primitive>(kScalarFloordiv);
115 inline const PrimitivePtr kPrimScalarMod = std::make_shared<Primitive>(kScalarMod);
116 inline const PrimitivePtr kPrimScalarPow = std::make_shared<Primitive>(kScalarPow);
117 inline const PrimitivePtr kPrimScalarTrunc = std::make_shared<Primitive>(kScalarTrunc);
118 inline const PrimitivePtr kPrimScalarFloor = std::make_shared<Primitive>(kScalarFloor);
119 inline const PrimitivePtr kPrimScalarUadd = std::make_shared<Primitive>(kScalarUadd);
120 inline const PrimitivePtr kPrimScalarUsub = std::make_shared<Primitive>(kScalarUsub);
121 inline const PrimitivePtr kPrimScalarExp = std::make_shared<Primitive>("scalar_exp");
122 inline const PrimitivePtr kPrimScalarLog = std::make_shared<Primitive>("scalar_log");
123 inline const PrimitivePtr kPrimScalarSin = std::make_shared<Primitive>("scalar_sin");
124 inline const PrimitivePtr kPrimScalarCos = std::make_shared<Primitive>("scalar_cos");
125 inline const PrimitivePtr kPrimScalarTan = std::make_shared<Primitive>("scalar_tan");
126 
127 // Comparisons
128 inline const PrimitivePtr kPrimScalarEq = std::make_shared<Primitive>("scalar_eq");
129 inline const PrimitivePtr kPrimScalarLt = std::make_shared<Primitive>("scalar_lt");
130 inline const PrimitivePtr kPrimScalarGt = std::make_shared<Primitive>("scalar_gt");
131 inline const PrimitivePtr kPrimScalarNe = std::make_shared<Primitive>("scalar_ne");
132 inline const PrimitivePtr kPrimScalarLe = std::make_shared<Primitive>("scalar_le");
133 inline const PrimitivePtr kPrimScalarGe = std::make_shared<Primitive>("scalar_ge");
134 inline const PrimitivePtr kPrimBoolNot = std::make_shared<Primitive>("bool_not");
135 inline const PrimitivePtr kPrimBoolAnd = std::make_shared<Primitive>("bool_and");
136 inline const PrimitivePtr kPrimBoolOr = std::make_shared<Primitive>("bool_or");
137 inline const PrimitivePtr kPrimBoolEq = std::make_shared<Primitive>("bool_eq");
138 inline const PrimitivePtr kPrimGreater = std::make_shared<Primitive>("Greater");
139 inline const PrimitivePtr kPrimGreaterEqual = std::make_shared<Primitive>("GreaterEqual");
140 inline const PrimitivePtr kPrimLess = std::make_shared<Primitive>("Less");
141 inline const PrimitivePtr kPrimLessEqual = std::make_shared<Primitive>("LessEqual");
142 inline const PrimitivePtr kPrimEqual = std::make_shared<Primitive>(kEqual);
143 inline const PrimitivePtr kPrimNotEqual = std::make_shared<Primitive>(kNotEqual);
144 inline const PrimitivePtr kPrimLogicalAnd = std::make_shared<Primitive>("LogicalAnd");
145 inline const PrimitivePtr kPrimLogicalOr = std::make_shared<Primitive>("LogicalOr");
146 inline const PrimitivePtr kPrimLogicalNot = std::make_shared<Primitive>("LogicalNot");
147 inline const PrimitivePtr kPrimEqualCount = std::make_shared<Primitive>("EqualCount");
148 
149 inline const PrimitivePtr kPrimDistribute = std::make_shared<Primitive>("distribute");
150 inline const PrimitivePtr kPrimIm2Col = std::make_shared<Primitive>("im2col");
151 inline const PrimitivePtr kPrimCol2Im = std::make_shared<Primitive>("col2im");
152 inline const PrimitivePtr kPrimIm2ColV1 = std::make_shared<Primitive>("im2col_v1");
153 inline const PrimitivePtr kPrimCol2ImV1 = std::make_shared<Primitive>("col2im_v1");
154 
155 inline const PrimitivePtr kPrimLabelGoto = std::make_shared<Primitive>("LabelGoto");
156 inline const PrimitivePtr kPrimLabelSwitch = std::make_shared<Primitive>("LabelSwitch");
157 inline const PrimitivePtr kPrimLabelSet = std::make_shared<Primitive>("LabelSet");
158 
159 // Stack ops
160 inline const PrimitivePtr kPrimStackInit = std::make_shared<Primitive>("StackInit");
161 inline const PrimitivePtr kPrimStackDestroy = std::make_shared<Primitive>("StackDestroy");
162 inline const PrimitivePtr kPrimStackPush = std::make_shared<Primitive>("StackPush");
163 inline const PrimitivePtr kPrimStackPop = std::make_shared<Primitive>("StackPop");
164 
165 // Arrays
166 inline const PrimitivePtr kPrimBroadcastTo = std::make_shared<Primitive>("BroadcastTo");
167 inline const PrimitivePtr kPrimScalarToArray = std::make_shared<Primitive>("scalar_to_array");
168 inline const PrimitivePtr kPrimTopK = std::make_shared<Primitive>("TopK");
169 inline const PrimitivePtr kPrimArrayToScalar = std::make_shared<Primitive>("array_to_scalar");
170 inline const PrimitivePtr kPrimBroadcastShape = std::make_shared<Primitive>("broadcast_shape");
171 inline const PrimitivePtr kPrimArrayMap = std::make_shared<Primitive>("array_map");
172 inline const PrimitivePtr kPrimArrayReduce = std::make_shared<Primitive>("array_reduce");
173 inline const PrimitivePtr kPrimCast = std::make_shared<Primitive>("Cast");
174 inline const PrimitivePtr kPrimConcat = std::make_shared<Primitive>("Concat");
175 inline const PrimitivePtr kPrimSqueeze = std::make_shared<Primitive>("Squeeze");
176 inline const PrimitivePtr kPrimUnsqueeze = std::make_shared<Primitive>("Unsqueeze");
177 inline const PrimitivePtr kPrimTranspose = std::make_shared<Primitive>(kTranspose);
178 inline const PrimitivePtr kPrimGatherV2 = std::make_shared<Primitive>("GatherV2");
179 inline const PrimitivePtr kPrimGatherD = std::make_shared<Primitive>("GatherD");
180 inline const PrimitivePtr kPrimGather = std::make_shared<Primitive>("Gather");
181 inline const PrimitivePtr kPrimGatherND = std::make_shared<Primitive>("GatherND");
182 inline const PrimitivePtr kPrimSparseGatherV2 = std::make_shared<Primitive>("SparseGatherV2");
183 inline const PrimitivePtr kPrimSparseToDense = std::make_shared<Primitive>("SparseToDense");
184 inline const PrimitivePtr kPrimShape = std::make_shared<Primitive>("Shape");
185 inline const PrimitivePtr kPrimStridedSlice = std::make_shared<Primitive>(kStridedSlice);
186 inline const PrimitivePtr kPrimDynamicShape = std::make_shared<Primitive>(kDynamicShape);
187 inline const PrimitivePtr kPrimEmbeddingLookup = std::make_shared<Primitive>("EmbeddingLookup");
188 inline const PrimitivePtr kPrimEmbeddingLookupCommGrad = std::make_shared<Primitive>("EmbeddingLookupCommGrad");
189 inline const PrimitivePtr kPrimSize = std::make_shared<Primitive>("Size");
190 inline const PrimitivePtr kPrimArgMax = std::make_shared<Primitive>("Argmax");
191 inline const PrimitivePtr kPrimArgMin = std::make_shared<Primitive>("Argmin");
192 inline const PrimitivePtr kPrimPack = std::make_shared<Primitive>("Pack");
193 inline const PrimitivePtr kPrimStack = std::make_shared<Primitive>(kStack);
194 inline const PrimitivePtr kPrimUnpack = std::make_shared<Primitive>("Unpack");
195 inline const PrimitivePtr kPrimUnstack = std::make_shared<Primitive>(kUnstack);
196 inline const PrimitivePtr kPrimUnsortedSegmentMax = std::make_shared<Primitive>("UnsortedSegmentMax");
197 inline const PrimitivePtr kPrimUnsortedSegmentSum = std::make_shared<Primitive>("UnsortedSegmentSum");
198 inline const PrimitivePtr kPrimUnsortedSegmentMin = std::make_shared<Primitive>("UnsortedSegmentMin");
199 inline const PrimitivePtr kPrimConcatOffset = std::make_shared<Primitive>("ConcatOffset");
200 inline const PrimitivePtr kPrimReshape = std::make_shared<Primitive>("Reshape");
201 inline const PrimitivePtr kPrimSubAndFilter = std::make_shared<Primitive>("SubAndFilter");
202 inline const PrimitivePtr kPrimMapCacheIdx = std::make_shared<Primitive>("MapCacheIdx");
203 inline const PrimitivePtr kPrimUpdateCache = std::make_shared<Primitive>("UpdateCache");
204 inline const PrimitivePtr kPrimComputeAccidentalHits = std::make_shared<Primitive>("ComputeAccidentalHits");
205 inline const PrimitivePtr kPrimCacheSwapTable = std::make_shared<Primitive>("CacheSwapTable");
206 inline const PrimitivePtr kPrimDynamicAssign = std::make_shared<Primitive>("DynamicAssign");
207 inline const PrimitivePtr kPrimPadAndShift = std::make_shared<Primitive>("PadAndShift");
208 inline const PrimitivePtr kPrimSlice = std::make_shared<Primitive>("Slice");
209 inline const PrimitivePtr kPrimSliceGrad = std::make_shared<Primitive>("SliceGrad");
210 inline const PrimitivePtr kPrimSliceFusion = std::make_shared<Primitive>("SliceFusion");
211 inline const PrimitivePtr kPrimTile = std::make_shared<Primitive>(kTile);
212 inline const PrimitivePtr kPrimAddN = std::make_shared<Primitive>("AddN");
213 inline const PrimitivePtr kPrimAccumulateNV2 = std::make_shared<Primitive>("AccumulateNV2");
214 inline const PrimitivePtr kPrimTransData = std::make_shared<Primitive>("TransData");
215 inline const PrimitivePtr kPrimTransDataRNN = std::make_shared<Primitive>("TransDataRNN");
216 inline const PrimitivePtr kPrimNMSWithMask = std::make_shared<Primitive>("NMSWithMask");
217 inline const PrimitivePtr kPrimPad = std::make_shared<Primitive>("Pad");
218 inline const PrimitivePtr kPrimArgMaxWithValue = std::make_shared<Primitive>("ArgMaxWithValue");
219 inline const PrimitivePtr kPrimUnique = std::make_shared<Primitive>("Unique");
220 inline const PrimitivePtr kPrimUniqueGrad = std::make_shared<Primitive>("UniqueGrad");
221 inline const PrimitivePtr kPrimExtractImagePatches = std::make_shared<Primitive>("ExtractImagePatches");
222 inline const PrimitivePtr kPrimDynamicRNN = std::make_shared<Primitive>("DynamicRNN");
223 inline const PrimitivePtr kPrimDynamicRNNGrad = std::make_shared<Primitive>("DynamicRNNGrad");
224 inline const PrimitivePtr kPrimDynamicGRUV2 = std::make_shared<Primitive>("DynamicGRUV2");
225 inline const PrimitivePtr kPrimDynamicGRUV2Grad = std::make_shared<Primitive>("DynamicGRUV2Grad");
226 inline const PrimitivePtr kPrimScatterAdd = std::make_shared<Primitive>("ScatterAdd");
227 inline const PrimitivePtr kPrimScatterSub = std::make_shared<Primitive>("ScatterSub");
228 inline const PrimitivePtr kPrimScatterMul = std::make_shared<Primitive>("ScatterMul");
229 inline const PrimitivePtr kPrimScatterDiv = std::make_shared<Primitive>("ScatterDiv");
230 inline const PrimitivePtr kPrimScatterMax = std::make_shared<Primitive>("ScatterMax");
231 inline const PrimitivePtr kPrimScatterMin = std::make_shared<Primitive>("ScatterMin");
232 inline const PrimitivePtr kPrimScatterUpdate = std::make_shared<Primitive>("ScatterUpdate");
233 inline const PrimitivePtr kPrimTensorCopySlices = std::make_shared<Primitive>("TensorCopySlices");
234 inline const PrimitivePtr kPrimMapUniform = std::make_shared<Primitive>("MapUniform");
235 inline const PrimitivePtr kPrimSplit = std::make_shared<Primitive>("Split");
236 inline const PrimitivePtr kPrimSplitV = std::make_shared<Primitive>(kSplitV);
237 inline const PrimitivePtr kPrimSequenceMask = std::make_shared<Primitive>("SequenceMask");
238 inline const PrimitivePtr kPrimRange = std::make_shared<Primitive>("Range");
239 inline const PrimitivePtr kPrimSpaceToBatchND = std::make_shared<Primitive>("SpaceToBatchND");
240 inline const PrimitivePtr kPrimBatchToSpaceND = std::make_shared<Primitive>("BatchToSpaceND");
241 inline const PrimitivePtr kPrimDepthToSpace = std::make_shared<Primitive>("DepthToSpace");
242 inline const PrimitivePtr kPrimBatchToSpace = std::make_shared<Primitive>("BatchToSpace");
243 inline const PrimitivePtr kPrimSpaceToBatch = std::make_shared<Primitive>("SpaceToBatch");
244 inline const PrimitivePtr kPrimScatterNd = std::make_shared<Primitive>("ScatterNd");
245 inline const PrimitivePtr kPrimConstantOfShape = std::make_shared<Primitive>("ConstantOfShape");
246 inline const PrimitivePtr kPrimSquaredDifference = std::make_shared<Primitive>("SquaredDifference");
247 inline const PrimitivePtr kPrimReverseV2 = std::make_shared<Primitive>("ReverseV2");
248 inline const PrimitivePtr kPrimReverseSequence = std::make_shared<Primitive>("ReverseSequence");
249 inline const PrimitivePtr kPrimRank = std::make_shared<Primitive>("Rank");
250 inline const PrimitivePtr kPrimResizeBilinear = std::make_shared<Primitive>("ResizeBilinear");
251 inline const PrimitivePtr kPrimResizeGrad = std::make_shared<Primitive>("ResizeGrad");
252 inline const PrimitivePtr kPrimResizeNearestNeighbor = std::make_shared<Primitive>("ResizeNearestNeighbor");
253 inline const PrimitivePtr kPrimSort = std::make_shared<Primitive>("Sort");
254 inline const PrimitivePtr kPrimMaskedFill = std::make_shared<Primitive>("MaskedFill");
255 inline const PrimitivePtr kPrimMaskedSelect = std::make_shared<Primitive>("MaskedSelect");
256 inline const PrimitivePtr kPrimDiag = std::make_shared<Primitive>(kDiag);
257 inline const PrimitivePtr kPrimDiagPart = std::make_shared<Primitive>(kDiagPart);
258 
259 // NN
260 inline const PrimitivePtr kPrimAdam = std::make_shared<Primitive>("Adam");
261 inline const PrimitivePtr kPrimAudioSpectrogram = std::make_shared<Primitive>("AudioSpectrogram");
262 inline const PrimitivePtr kPrimFlatten = std::make_shared<Primitive>("Flatten");
263 inline const PrimitivePtr kPrimCrop = std::make_shared<Primitive>("Crop");
264 inline const PrimitivePtr kPrimFlattenGrad = std::make_shared<Primitive>("FlattenGrad");
265 inline const PrimitivePtr kPrimSoftmax = std::make_shared<Primitive>("Softmax");
266 inline const PrimitivePtr kPrimSparseSoftmaxCrossEntropy = std::make_shared<Primitive>("SparseSoftmaxCrossEntropy");
267 inline const PrimitivePtr kPrimLogSoftmax = std::make_shared<Primitive>("LogSoftmax");
268 inline const PrimitivePtr kPrimLogSoftmaxGrad = std::make_shared<Primitive>("LogSoftmaxGrad");
269 inline const PrimitivePtr kPrimLstm = std::make_shared<Primitive>("LSTM");
270 inline const PrimitivePtr kPrimTan = std::make_shared<Primitive>("Tan");
271 inline const PrimitivePtr kPrimAtan2 = std::make_shared<Primitive>("Atan2");
272 inline const PrimitivePtr kPrimAtan = std::make_shared<Primitive>("Atan");
273 inline const PrimitivePtr kPrimAsin = std::make_shared<Primitive>("Asin");
274 inline const PrimitivePtr kPrimSinh = std::make_shared<Primitive>("Sinh");
275 inline const PrimitivePtr kPrimCosh = std::make_shared<Primitive>("Cosh");
276 inline const PrimitivePtr kPrimTanh = std::make_shared<Primitive>("Tanh");
277 inline const PrimitivePtr kPrimAsinh = std::make_shared<Primitive>("Asinh");
278 inline const PrimitivePtr kPrimAcosh = std::make_shared<Primitive>("Acosh");
279 inline const PrimitivePtr kPrimAtanh = std::make_shared<Primitive>("Atanh");
280 inline const PrimitivePtr kPrimTanhGrad = std::make_shared<Primitive>("TanhGrad");
281 inline const PrimitivePtr kPrimPooling = std::make_shared<Primitive>("Pooling");
282 inline const PrimitivePtr kPrimPoolingGrad = std::make_shared<Primitive>("PoolingGrad");
283 inline const PrimitivePtr kPrimROIPooling = std::make_shared<Primitive>("ROIPooling");
284 inline const PrimitivePtr kPrimMaxPool = std::make_shared<Primitive>("MaxPool");
285 inline const PrimitivePtr kPrimMaxPoolGrad = std::make_shared<Primitive>("MaxPoolGrad");
286 inline const PrimitivePtr kPrimMaxPoolWithArgmax = std::make_shared<Primitive>("MaxPoolWithArgmax");
287 inline const PrimitivePtr kPrimMaxPoolGradWithArgmax = std::make_shared<Primitive>("MaxPoolGradWithArgmax");
288 inline const PrimitivePtr kPrimApplyCenteredRMSProp = std::make_shared<Primitive>("ApplyCenteredRMSProp");
289 inline const PrimitivePtr kPrimAvgPool = std::make_shared<Primitive>("AvgPool");
290 inline const PrimitivePtr kPrimAvgPool3D = std::make_shared<Primitive>("AvgPool3D");
291 inline const PrimitivePtr kPrimAvgPoolGrad = std::make_shared<Primitive>("AvgPoolGrad");
292 inline const PrimitivePtr kPrimAvgPool3DGrad = std::make_shared<Primitive>("AvgPool3DGrad");
293 inline const PrimitivePtr kPrimAvgPoolGradVm = std::make_shared<Primitive>("AvgPoolGradVm");
294 inline const PrimitivePtr kPrimFusedSparseAdam = std::make_shared<Primitive>("FusedSparseAdam");
295 inline const PrimitivePtr kPrimFusedBatchNorm = std::make_shared<Primitive>("FusedBatchNorm");
296 inline const PrimitivePtr kPrimConv2D = std::make_shared<Primitive>("Conv2D");
297 inline const PrimitivePtr kPrimConv3D = std::make_shared<Primitive>("Conv3D");
298 inline const PrimitivePtr kPrimCTCLossV2 = std::make_shared<Primitive>("CTCLossV2");
299 inline const PrimitivePtr kPrimCTCLossV2Grad = std::make_shared<Primitive>("CTCLossV2Grad");
300 inline const PrimitivePtr kPrimCTCLoss = std::make_shared<Primitive>(kCTCLoss);
301 inline const PrimitivePtr kPrimFullConnection = std::make_shared<Primitive>("FullConnection");
302 inline const PrimitivePtr kPrimConv2DTranspose = std::make_shared<Primitive>(kConv2DTranspose);
303 inline const PrimitivePtr kPrimConv3DTranspose = std::make_shared<Primitive>("Conv3DTranspose");
304 inline const PrimitivePtr kPrimRoll = std::make_shared<Primitive>(kRoll);
305 inline const PrimitivePtr kPrimGroupConv2DGradInput = std::make_shared<Primitive>("GroupConv2DGradInput");
306 inline const PrimitivePtr kPrimBatchNorm = std::make_shared<Primitive>("BatchNorm");
307 inline const PrimitivePtr kPrimBatchNormGrad = std::make_shared<Primitive>("BatchNormGrad");
308 inline const PrimitivePtr kPrimSyncBatchNorm = std::make_shared<Primitive>("SyncBatchNorm");
309 inline const PrimitivePtr kPrimSyncBatchNormGrad = std::make_shared<Primitive>("SyncBatchNormGrad");
310 inline const PrimitivePtr kPrimBNTrainingReduceGrad = std::make_shared<Primitive>("BNTrainingReduceGrad");
311 inline const PrimitivePtr kPrimReluGrad = std::make_shared<Primitive>(kReLUGrad);
312 inline const PrimitivePtr kPrimReluGradV2 = std::make_shared<Primitive>("ReluGradV2");
313 inline const PrimitivePtr kPrimRelu6Grad = std::make_shared<Primitive>("ReLU6Grad");
314 inline const PrimitivePtr kPrimConv2DBackpropInput = std::make_shared<Primitive>("Conv2DBackpropInput");
315 inline const PrimitivePtr kPrimConv2DBackpropFilter = std::make_shared<Primitive>("Conv2DBackpropFilter");
316 inline const PrimitivePtr kPrimConv3DBackpropInput = std::make_shared<Primitive>("Conv3DBackpropInput");
317 inline const PrimitivePtr kPrimConv3DBackpropFilter = std::make_shared<Primitive>("Conv3DBackpropFilter");
318 inline const PrimitivePtr kPrimCustomNormalize = std::make_shared<Primitive>("CustomNormalize");
319 inline const PrimitivePtr kPrimDepthwiseConv2dNative = std::make_shared<Primitive>("DepthwiseConv2dNative");
320 inline const PrimitivePtr kPrimCTCGreedyDecoder = std::make_shared<Primitive>("CTCGreedyDecoder");
321 inline const PrimitivePtr kPrimDynamicStitch = std::make_shared<Primitive>("DynamicStitch");
322 inline const PrimitivePtr kPrimDepthwiseConv2dNativeBackpropFilter =
323   std::make_shared<Primitive>("DepthwiseConv2dNativeBackpropFilter");
324 inline const PrimitivePtr kPrimDepthwiseConv2dNativeBackpropInput =
325   std::make_shared<Primitive>("DepthwiseConv2dNativeBackpropInput");
326 inline const PrimitivePtr kPrimDetectionPostProcess = std::make_shared<Primitive>("DetectionPostProcess");
327 inline const PrimitivePtr kPrimBiasAddGrad = std::make_shared<Primitive>(kBiasAddGrad);
328 inline const PrimitivePtr kPrimBiasAdd = std::make_shared<Primitive>(kBiasAdd);
329 inline const PrimitivePtr kPrimBiasSubGrad = std::make_shared<Primitive>("BiasSubGrad");
330 inline const PrimitivePtr kPrimBinaryCrossEntropy = std::make_shared<Primitive>("BinaryCrossEntropy");
331 inline const PrimitivePtr kPrimBinaryCrossEntropyGrad = std::make_shared<Primitive>("BinaryCrossEntropyGrad");
332 inline const PrimitivePtr kPrimSmoothL1Loss = std::make_shared<Primitive>("SmoothL1Loss");
333 inline const PrimitivePtr kPrimSmoothL1LossGrad = std::make_shared<Primitive>("SmoothL1LossGrad");
334 inline const PrimitivePtr kPrimSoftMarginLoss = std::make_shared<Primitive>("SoftMarginLoss");
335 inline const PrimitivePtr kPrimSoftMarginLossGrad = std::make_shared<Primitive>("SoftMarginLossGrad");
336 inline const PrimitivePtr kPrimSoftmaxCrossEntropyWithLogits =
337   std::make_shared<Primitive>("SoftmaxCrossEntropyWithLogits");
338 inline const PrimitivePtr kPrimSigmoidCrossEntropyWithLogits =
339   std::make_shared<Primitive>("SigmoidCrossEntropyWithLogits");
340 inline const PrimitivePtr kPrimSigmoidCrossEntropyWithLogitsGrad =
341   std::make_shared<Primitive>("SigmoidCrossEntropyWithLogitsGrad");
342 inline const PrimitivePtr kPrimSparseSoftmaxCrossEntropyWithLogits =
343   std::make_shared<Primitive>("SparseSoftmaxCrossEntropyWithLogits");
344 inline const PrimitivePtr kPrimMomentum = std::make_shared<Primitive>("Momentum");
345 inline const PrimitivePtr kPrimApplyMomentum = std::make_shared<Primitive>("ApplyMomentum");
346 inline const PrimitivePtr kPrimApplyFtrl = std::make_shared<Primitive>("ApplyFtrl");
347 inline const PrimitivePtr kPrimLrn = std::make_shared<Primitive>("LRN");
348 inline const PrimitivePtr kPrimLayerNorm = std::make_shared<Primitive>(kLayerNorm);
349 inline const PrimitivePtr kPrimLayerNormGrad = std::make_shared<Primitive>(kLayerNormGrad);
350 inline const PrimitivePtr kPrimLayerNormXBackprop = std::make_shared<Primitive>("LayerNormXBackprop");
351 inline const PrimitivePtr kPrimLayerNormXBackpropV2 = std::make_shared<Primitive>("LayerNormXBackpropV2");
352 inline const PrimitivePtr kPrimLayerNormBetaGammaBackprop = std::make_shared<Primitive>("LayerNormBetaGammaBackprop");
353 inline const PrimitivePtr kPrimLayerNormBetaGammaBackpropV2 =
354   std::make_shared<Primitive>("LayerNormBetaGammaBackpropV2");
355 inline const PrimitivePtr kPrimLog1p = std::make_shared<Primitive>("Log1p");
356 inline const PrimitivePtr kPrimDropoutGenMask = std::make_shared<Primitive>(kDropoutGenMask);
357 inline const PrimitivePtr kPrimDropoutDoMask = std::make_shared<Primitive>(kDropoutDoMask);
358 inline const PrimitivePtr kPrimDropoutGrad = std::make_shared<Primitive>(kDropoutGrad);
359 inline const PrimitivePtr kPrimDropout = std::make_shared<Primitive>(kDropout);
360 inline const PrimitivePtr kPrimUniformReal = std::make_shared<Primitive>("UniformReal");
361 inline const PrimitivePtr kPrimCudnnUniformReal = std::make_shared<Primitive>("CudnnUniformReal");
362 inline const PrimitivePtr kPrimOneHot = std::make_shared<Primitive>("OneHot");
363 inline const PrimitivePtr kPrimGeLU = std::make_shared<Primitive>(kGeLU);
364 inline const PrimitivePtr kPrimGeLUGrad = std::make_shared<Primitive>(kGeLUGrad);
365 inline const PrimitivePtr kPrimFastGeLU = std::make_shared<Primitive>(kFastGeLU);
366 inline const PrimitivePtr kPrimFastGeLUGrad = std::make_shared<Primitive>(kFastGeLUGrad);
367 inline const PrimitivePtr kPrimRelu = std::make_shared<Primitive>(kReLU);
368 inline const PrimitivePtr kPrimElu = std::make_shared<Primitive>("Elu");
369 inline const PrimitivePtr kPrimRelu6 = std::make_shared<Primitive>(kReLU6);
370 inline const PrimitivePtr kPrimReluV2 = std::make_shared<Primitive>(kReLUV2);
371 inline const PrimitivePtr kPrimPRelu = std::make_shared<Primitive>("PReLU");
372 inline const PrimitivePtr kPrimSoftplus = std::make_shared<Primitive>("Softplus");
373 inline const PrimitivePtr kPrimSoftplusGrad = std::make_shared<Primitive>("SoftplusGrad");
374 inline const PrimitivePtr kPrimZeros = std::make_shared<Primitive>("Zeros");
375 inline const PrimitivePtr kPrimZerosLike = std::make_shared<Primitive>(kZerosLike);
376 inline const PrimitivePtr kPrimOnes = std::make_shared<Primitive>(kOnes);
377 inline const PrimitivePtr kPrimOnesLike = std::make_shared<Primitive>(kOnesLike);
378 inline const PrimitivePtr kPrimBpropCut = std::make_shared<Primitive>("bprop_cut");
379 inline const PrimitivePtr kPrimFakeQuantPerLayer = std::make_shared<Primitive>("FakeQuantPerLayer");
380 inline const PrimitivePtr kPrimFakeQuantPerChannel = std::make_shared<Primitive>("FakeQuantPerChannel");
381 inline const PrimitivePtr kPrimFakeLearnedScaleQuantPerLayer =
382   std::make_shared<Primitive>("FakeLearnedScaleQuantPerLayer");
383 inline const PrimitivePtr kPrimFakeLearnedScaleQuantPerChannel =
384   std::make_shared<Primitive>("FakeLearnedScaleQuantPerChannel");
385 inline const PrimitivePtr kPrimFakeQuantWithMinMaxVars = std::make_shared<Primitive>("FakeQuantWithMinMaxVars");
386 inline const PrimitivePtr kPrimApplyRMSProp = std::make_shared<Primitive>("ApplyRMSProp");
387 inline const PrimitivePtr kPrimSparseApplyFtrl = std::make_shared<Primitive>("SparseApplyFtrl");
388 inline const PrimitivePtr kPrimSparseApplyProximalAdagrad = std::make_shared<Primitive>("SparseApplyProximalAdagrad");
389 inline const PrimitivePtr kPrimFusedAdam = std::make_shared<Primitive>("FusedAdam");
390 inline const PrimitivePtr kPrimFusedAdamWeightDecay = std::make_shared<Primitive>("FusedAdamWeightDecay");
391 inline const PrimitivePtr kPrimSGD = std::make_shared<Primitive>("SGD");
392 inline const PrimitivePtr kPrimBCEWithLogitsLoss = std::make_shared<Primitive>("BCEWithLogitsLoss");
393 inline const PrimitivePtr kPrimClipByNormNoDivSum = std::make_shared<Primitive>("ClipByNormNoDivSum");
394 inline const PrimitivePtr kPrimTensorMove = std::make_shared<Primitive>("TensorMove");
395 inline const PrimitivePtr kPrimL2Normalize = std::make_shared<Primitive>("L2Normalize");
396 inline const PrimitivePtr kPrimCustomExtractFeatures = std::make_shared<Primitive>("CustomExtractFeatures");
397 inline const PrimitivePtr kLambApplyOptimizerAssign = std::make_shared<Primitive>("LambApplyOptimizerAssign");
398 inline const PrimitivePtr kLambApplyWeightAssign = std::make_shared<Primitive>("LambApplyWeightAssign");
399 inline const PrimitivePtr kSoftmaxGradExt = std::make_shared<Primitive>("SoftmaxGradExt");
400 inline const PrimitivePtr kSquareSumV1 = std::make_shared<Primitive>("SquareSumV1");
401 inline const PrimitivePtr kFusedMulAdd = std::make_shared<Primitive>("FusedMulAdd");
402 inline const PrimitivePtr kPrimSoftShrink = std::make_shared<Primitive>("SoftShrink");
403 inline const PrimitivePtr kPrimSoftShrinkGrad = std::make_shared<Primitive>("SoftShrinkGrad");
404 inline const PrimitivePtr kPrimHShrink = std::make_shared<Primitive>("HShrink");
405 inline const PrimitivePtr kPrimHShrinkGrad = std::make_shared<Primitive>("HShrinkGrad");
406 inline const PrimitivePtr kPrimApplyAdagradDA = std::make_shared<Primitive>("ApplyAdagradDA");
407 inline const PrimitivePtr kPrimSparseApplyRMSProp = std::make_shared<Primitive>("SparseApplyRMSProp");
408 
409 // Comm ops
410 inline const PrimitivePtr kPrimMirror = std::make_shared<Primitive>("_MirrorOperator");
411 inline const PrimitivePtr kPrimMirrorMiniStep = std::make_shared<Primitive>("_MirrorMiniStepOperator");
412 inline const PrimitivePtr kPrimMiniStepAllGather = std::make_shared<Primitive>("_MiniStepAllGather");
413 inline const PrimitivePtr kPrimMicroStepAllGather = std::make_shared<Primitive>("_MicroStepAllGather");
414 inline const PrimitivePtr kPrimVirtualDiv = std::make_shared<Primitive>("_VirtualDiv");
415 inline const PrimitivePtr kPrimVirtualAdd = std::make_shared<Primitive>("_VirtualAdd");
416 inline const PrimitivePtr kPrimVirtualDataset = std::make_shared<Primitive>("_VirtualDataset");
417 inline const PrimitivePtr kPrimVirtualOutput = std::make_shared<Primitive>("_VirtualOutput");
418 inline const PrimitivePtr kPrimSend = std::make_shared<Primitive>("Send");
419 inline const PrimitivePtr kPrimReceive = std::make_shared<Primitive>("Receive");
420 inline const PrimitivePtr kPrimAllReduce = std::make_shared<Primitive>("AllReduce");
421 inline const PrimitivePtr kPrimNeighborExchange = std::make_shared<Primitive>("NeighborExchange");
422 inline const PrimitivePtr kPrimAllToAll = std::make_shared<Primitive>("AlltoAll");
423 inline const PrimitivePtr kPrimAllToAllv = std::make_shared<Primitive>("AllToAllv");
424 inline const PrimitivePtr kPrimAllSwap = std::make_shared<Primitive>("AllSwap");
425 inline const PrimitivePtr kPrimBroadcast = std::make_shared<Primitive>("Broadcast");
426 inline const PrimitivePtr kPrimAllGather = std::make_shared<Primitive>("AllGather");
427 inline const PrimitivePtr kPrimReduceScatter = std::make_shared<Primitive>("ReduceScatter");
428 inline const PrimitivePtr kPrimMemCpyAsync = std::make_shared<Primitive>("memcpy_async");
429 inline const PrimitivePtr kPrimFill = std::make_shared<Primitive>("Fill");
430 inline const PrimitivePtr kPrimFusedPushWeight = std::make_shared<Primitive>("FusedPushWeight");
431 inline const PrimitivePtr kPrimFusedPullWeight = std::make_shared<Primitive>("FusedPullWeight");
432 inline const PrimitivePtr kPrimInitDataSetQueue = std::make_shared<Primitive>("InitDataSetQueue");
433 inline const PrimitivePtr kPrimVirtualAssignAdd = std::make_shared<Primitive>("_VirtualAssignAdd");
434 inline const PrimitivePtr kPrimVirtualAccuGrad = std::make_shared<Primitive>("_VirtualAccuGrad");
435 inline const PrimitivePtr kPrimMirrorMicroStep = std::make_shared<Primitive>("_MirrorMicroStepOperator");
436 
437 // Quant ops
438 inline const PrimitivePtr kPrimBatchNormFold = std::make_shared<Primitive>("BatchNormFold");
439 inline const PrimitivePtr kPrimFakeQuantWithMinMaxVarsPerChannel =
440   std::make_shared<Primitive>("FakeQuantWithMinMaxVarsPerChannel");
441 // Control ops
442 inline const PrimitivePtr kPrimMerge = std::make_shared<Primitive>("Merge");
443 // RowTensor
444 inline const PrimitivePtr kPrimMakeRowTensor = std::make_shared<Primitive>("MakeRowTensor");
445 inline const PrimitivePtr kPrimRowTensorGetValues = std::make_shared<Primitive>("RowTensorGetValues");
446 inline const PrimitivePtr kPrimRowTensorGetIndices = std::make_shared<Primitive>("RowTensorGetIndices");
447 inline const PrimitivePtr kPrimRowTensorGetDenseShape = std::make_shared<Primitive>("RowTensorGetDenseShape");
448 inline const PrimitivePtr kPrimRowTensorAdd = std::make_shared<Primitive>("RowTensorAdd");
449 
450 // SparseTensor
451 inline const PrimitivePtr kPrimMakeSparseTensor = std::make_shared<Primitive>("MakeSparseTensor");
452 inline const PrimitivePtr kPrimSparseTensorGetValues = std::make_shared<Primitive>("SparseTensorGetValues");
453 inline const PrimitivePtr kPrimSparseTensorGetIndices = std::make_shared<Primitive>("SparseTensorGetIndices");
454 inline const PrimitivePtr kPrimSparseTensorGetDenseShape = std::make_shared<Primitive>("SparseTensorGetDenseShape");
455 
456 // TensorList
457 inline const PrimitivePtr kPrimTensorListFromTensor = std::make_shared<Primitive>("TensorListFromTensor");
458 inline const PrimitivePtr kPrimTensorListReserve = std::make_shared<Primitive>("TensorListReserve");
459 inline const PrimitivePtr kPrimTensorListStack = std::make_shared<Primitive>("TensorListStack");
460 inline const PrimitivePtr kPrimTensorListSetItem = std::make_shared<Primitive>("TensorListSetItem");
461 
462 // Maths
463 inline const PrimitivePtr kPrimCeil = std::make_shared<Primitive>("Ceil");
464 inline const PrimitivePtr kPrimTensorAdd = std::make_shared<Primitive>("TensorAdd");
465 inline const PrimitivePtr kPrimAdd = std::make_shared<Primitive>(kAdd);
466 inline const PrimitivePtr kPrimMatMul = std::make_shared<Primitive>("MatMul");
467 inline const PrimitivePtr kPrimMatrixDiag = std::make_shared<Primitive>("MatrixDiag");
468 inline const PrimitivePtr kPrimBatchMatMul = std::make_shared<Primitive>("BatchMatMul");
469 inline const PrimitivePtr kPrimMaximumGrad = std::make_shared<Primitive>("MaximumGrad");
470 inline const PrimitivePtr kPrimMinimumGrad = std::make_shared<Primitive>("MinimumGrad");
471 inline const PrimitivePtr kPrimReduce = std::make_shared<Primitive>("Reduce");
472 inline const PrimitivePtr kPrimReduceMean = std::make_shared<Primitive>("ReduceMean");
473 inline const PrimitivePtr kPrimReduceSum = std::make_shared<Primitive>("ReduceSum");
474 inline const PrimitivePtr kPrimReduceAll = std::make_shared<Primitive>("ReduceAll");
475 inline const PrimitivePtr kPrimReduceAny = std::make_shared<Primitive>("ReduceAny");
476 inline const PrimitivePtr kPrimReduceMax = std::make_shared<Primitive>("ReduceMax");
477 inline const PrimitivePtr kPrimReduceMin = std::make_shared<Primitive>("ReduceMin");
478 inline const PrimitivePtr kPrimCentralization = std::make_shared<Primitive>("Centralization");
479 inline const PrimitivePtr kPrimNeg = std::make_shared<Primitive>(kNeg);
480 inline const PrimitivePtr kPrimSin = std::make_shared<Primitive>("Sin");
481 inline const PrimitivePtr kPrimCos = std::make_shared<Primitive>(kCos);
482 inline const PrimitivePtr kPrimSub = std::make_shared<Primitive>(kSub);
483 inline const PrimitivePtr kPrimMul = std::make_shared<Primitive>(kMul);
484 inline const PrimitivePtr kPrimDiv = std::make_shared<Primitive>("Div");
485 inline const PrimitivePtr kPrimMod = std::make_shared<Primitive>("Mod");
486 inline const PrimitivePtr kPrimFloor = std::make_shared<Primitive>("Floor");
487 inline const PrimitivePtr kPrimDivNoNan = std::make_shared<Primitive>("DivNoNan");
488 inline const PrimitivePtr kPrimMinimum = std::make_shared<Primitive>("Minimum");
489 inline const PrimitivePtr kPrimMaximum = std::make_shared<Primitive>("Maximum");
490 inline const PrimitivePtr kPrimSquare = std::make_shared<Primitive>(kSquare);
491 inline const PrimitivePtr kPrimCumSum = std::make_shared<Primitive>("CumSum");
492 inline const PrimitivePtr kPrimCumProd = std::make_shared<Primitive>("CumProd");
493 inline const PrimitivePtr kPrimSubscalar = std::make_shared<Primitive>("Subscalar");
494 inline const PrimitivePtr kPrimInplaceAdd = std::make_shared<Primitive>("InplaceAdd");
495 inline const PrimitivePtr kPrimInplaceSub = std::make_shared<Primitive>("InplaceSub");
496 inline const PrimitivePtr kPrimPow = std::make_shared<Primitive>("Pow");
497 inline const PrimitivePtr kPrimPower = std::make_shared<Primitive>("Power");
498 inline const PrimitivePtr kPrimRealDiv = std::make_shared<Primitive>(kRealDiv);
499 inline const PrimitivePtr kPrimFloorDiv = std::make_shared<Primitive>("FloorDiv");
500 inline const PrimitivePtr kPrimSqrt = std::make_shared<Primitive>("Sqrt");
501 inline const PrimitivePtr kPrimSqrtGrad = std::make_shared<Primitive>("SqrtGrad");
502 inline const PrimitivePtr kPrimReciprocal = std::make_shared<Primitive>(kReciprocal);
503 inline const PrimitivePtr kPrimExpandDims = std::make_shared<Primitive>("ExpandDims");
504 inline const PrimitivePtr kPrimAbs = std::make_shared<Primitive>(kAbs);
505 inline const PrimitivePtr kPrimAbsGrad = std::make_shared<Primitive>("AbsGrad");
506 inline const PrimitivePtr kPrimRint = std::make_shared<Primitive>("Rint");
507 inline const PrimitivePtr kPrimRound = std::make_shared<Primitive>("Round");
508 inline const PrimitivePtr kPrimExp = std::make_shared<Primitive>(kExp);
509 inline const PrimitivePtr kPrimExpm1 = std::make_shared<Primitive>("Expm1");
510 inline const PrimitivePtr kPrimLog = std::make_shared<Primitive>(kLog);
511 inline const PrimitivePtr kPrimRsqrt = std::make_shared<Primitive>("Rsqrt");
512 inline const PrimitivePtr kPrimRsqrtGrad = std::make_shared<Primitive>("RsqrtGrad");
513 inline const PrimitivePtr kPrimLinSpace = std::make_shared<Primitive>("LinSpace");
514 inline const PrimitivePtr kPrimNonMaxSuppression = std::make_shared<Primitive>("NonMaxSuppression");
515 inline const PrimitivePtr kPrimSign = std::make_shared<Primitive>("Sign");
516 inline const PrimitivePtr kPrimACos = std::make_shared<Primitive>("ACos");
517 inline const PrimitivePtr kPrimAsinGrad = std::make_shared<Primitive>("AsinGrad");
518 inline const PrimitivePtr kPrimACosGrad = std::make_shared<Primitive>("ACosGrad");
519 inline const PrimitivePtr kPrimAtanGrad = std::make_shared<Primitive>("AtanGrad");
520 inline const PrimitivePtr kPrimAsinhGrad = std::make_shared<Primitive>("AsinhGrad");
521 inline const PrimitivePtr kPrimAcoshGrad = std::make_shared<Primitive>("AcoshGrad");
522 inline const PrimitivePtr kPrimFloorMod = std::make_shared<Primitive>("FloorMod");
523 inline const PrimitivePtr kPrimCdist = std::make_shared<Primitive>(kCdist);
524 inline const PrimitivePtr kPrimCdistGrad = std::make_shared<Primitive>(kCdistGrad);
525 inline const PrimitivePtr kPrimWhere = std::make_shared<Primitive>("Where");
526 inline const PrimitivePtr kPrimIndexAdd = std::make_shared<Primitive>("IndexAdd");
527 inline const PrimitivePtr kPrimIdentityMath = std::make_shared<Primitive>("Identity", kSideEffectPropagate);
528 inline const PrimitivePtr kPrimErfinv = std::make_shared<Primitive>("Erfinv");
529 inline const PrimitivePtr kPrimIsNan = std::make_shared<Primitive>("IsNan");
530 inline const PrimitivePtr kPrimIsInf = std::make_shared<Primitive>("IsInf");
531 inline const PrimitivePtr kPrimIsFinite = std::make_shared<Primitive>("IsFinite");
532 inline const PrimitivePtr kPrimLerp = std::make_shared<Primitive>("Lerp");
533 inline const PrimitivePtr kPrimSquareSumAll = std::make_shared<Primitive>("SquareSumAll");
534 
535 // Statements
536 inline const PrimitivePtr kPrimReturn = std::make_shared<Primitive>("Return");
537 inline const PrimitivePtr kPrimSwitch = std::make_shared<Primitive>("Switch");
538 inline const PrimitivePtr kPrimSwitchLayer = std::make_shared<Primitive>("switch_layer");
539 inline const PrimitivePtr kPrimAssign = std::make_shared<Primitive>("Assign");
540 inline const PrimitivePtr kPrimAssignAdd = std::make_shared<Primitive>("AssignAdd");
541 inline const PrimitivePtr kPrimAssignSub = std::make_shared<Primitive>("AssignSub");
542 inline const PrimitivePtr kPrimSelect = std::make_shared<Primitive>(kSelect);
543 inline const PrimitivePtr kPrimCall = std::make_shared<Primitive>("call");
544 
545 inline const PrimitivePtr kPrimMakeTuple = std::make_shared<Primitive>("MakeTuple");
546 inline const PrimitivePtr kPrimMakeSlice = std::make_shared<Primitive>("make_slice");
547 inline const PrimitivePtr kPrimTupleGetItem = std::make_shared<Primitive>(kTupleGetItem);
548 inline const PrimitivePtr kPrimArrayGetItem = std::make_shared<Primitive>("array_getitem");
549 inline const PrimitivePtr kPrimTupleSetItem = std::make_shared<Primitive>("tuple_setitem");
550 inline const PrimitivePtr kPrimArraySetItem = std::make_shared<Primitive>("array_setitem");
551 inline const PrimitivePtr kPrimGetAttr = std::make_shared<Primitive>("getattr");
552 inline const PrimitivePtr kPrimTupleLen = std::make_shared<Primitive>("tuple_len");
553 inline const PrimitivePtr kPrimArrayLen = std::make_shared<Primitive>("array_len");
554 inline const PrimitivePtr kPrimTileShape = std::make_shared<Primitive>("tile_shape");
555 inline const PrimitivePtr kPrimGenerateShapeIndex = std::make_shared<Primitive>("generate_shape_index");
556 inline const PrimitivePtr kPrimGenerateInverseIndex = std::make_shared<Primitive>("generate_inverse_index");
557 
558 // Debug ops
559 inline const PrimitivePtr kPrimAssert = std::make_shared<Primitive>("Assert");
560 #ifndef ENABLE_SECURITY
561 inline const PrimitivePtr kPrimScalarSummary = std::make_shared<Primitive>("ScalarSummary");
562 inline const PrimitivePtr kPrimImageSummary = std::make_shared<Primitive>("ImageSummary");
563 inline const PrimitivePtr kPrimTensorSummary = std::make_shared<Primitive>("TensorSummary");
564 inline const PrimitivePtr kPrimHistogramSummary = std::make_shared<Primitive>("HistogramSummary");
565 #endif
566 inline const PrimitivePtr kPrimDebug = std::make_shared<Primitive>("Debug");
567 
568 // Dynamic shape testing
569 inline const PrimitivePtr kPrimGpuConvertToDynamicShape = std::make_shared<Primitive>("GpuConvertToDynamicShape");
570 inline const PrimitivePtr kPrimErrorOnDynamicShapeInput = std::make_shared<Primitive>("ErrorOnDynamicShapeInput");
571 
572 // Other miscellaneous
573 inline const PrimitivePtr kPrimDepend = std::make_shared<Primitive>("Depend", kSideEffectPropagate);
574 inline const PrimitivePtr kPrimReformat = std::make_shared<Primitive>("Reformat");
575 inline const PrimitivePtr kPrimLoad = std::make_shared<Primitive>("Load");
576 inline const PrimitivePtr kPrimUpdateState = std::make_shared<Primitive>("UpdateState");
577 inline const PrimitivePtr kPrimPartial = std::make_shared<Primitive>("Partial", kSideEffectPropagate);
578 inline const PrimitivePtr kPrimIdentity = std::make_shared<Primitive>("identity", kSideEffectPropagate);
579 inline const PrimitivePtr kPrimHookBackward = std::make_shared<Primitive>("HookBackward");
580 inline const PrimitivePtr kPrimPrintShapeType = std::make_shared<Primitive>("PrintShapeType");
581 inline const PrimitivePtr kPrimSameTypeShape = std::make_shared<Primitive>("SameTypeShape");
582 inline const PrimitivePtr kPrimPrint = std::make_shared<Primitive>("Print");
583 inline const PrimitivePtr kPrimIs_ = std::make_shared<Primitive>("is_");
584 inline const PrimitivePtr kPrimIsNot = std::make_shared<Primitive>("is_not");
585 inline const PrimitivePtr kPrimInDict = std::make_shared<Primitive>("in_dict");
586 inline const PrimitivePtr kPrimNotInDict = std::make_shared<Primitive>("not_in_dict");
587 inline const PrimitivePtr kPrimIsConsant = std::make_shared<Primitive>("is_constant");
588 inline const PrimitivePtr kPrimEquivFormat = std::make_shared<Primitive>("EquivFormat");
589 inline const PrimitivePtr kPrimLshProjection = std::make_shared<Primitive>("LshProjection");
590 inline const PrimitivePtr kPrimHashtableLookup = std::make_shared<Primitive>("HashtableLookup");
591 inline const PrimitivePtr kPrimCustomPredict = std::make_shared<Primitive>("CustomPredict");
592 inline const PrimitivePtr kPrimPriorBox = std::make_shared<Primitive>("PriorBox");
593 inline const PrimitivePtr kPrimQuantDTypeCast = std::make_shared<Primitive>("QuantDTypeCast");
594 inline const PrimitivePtr kPrimWhile = std::make_shared<Primitive>("While");
595 inline const PrimitivePtr kPrimPull = std::make_shared<Primitive>("Pull");
596 inline const PrimitivePtr kPrimPush = std::make_shared<Primitive>("Push");
597 inline const PrimitivePtr kPrimNPUAllocFloatStatus = std::make_shared<Primitive>("NPUAllocFloatStatus");
598 inline const PrimitivePtr kPyFunc = std::make_shared<Primitive>("PyFunc");
599 
600 // Structures
601 inline const PrimitivePtr kPrimMakeList = std::make_shared<Primitive>("make_list");
602 inline const PrimitivePtr kPrimMakeKeywordArg = std::make_shared<Primitive>("make_keyword_arg");
603 inline const PrimitivePtr kPrimListGetItem = std::make_shared<Primitive>("list_getitem");
604 inline const PrimitivePtr kPrimListSetItem = std::make_shared<Primitive>("list_setitem");
605 inline const PrimitivePtr kPrimDictGetItem = std::make_shared<Primitive>("dict_getitem");
606 inline const PrimitivePtr kPrimDictSetItem = std::make_shared<Primitive>("dict_setitem");
607 inline const PrimitivePtr kPrimDictGetKeys = std::make_shared<Primitive>("dict_getkeys");
608 inline const PrimitivePtr kPrimDictGetValues = std::make_shared<Primitive>("dict_getvalues");
609 inline const PrimitivePtr kPrimListAppend = std::make_shared<Primitive>("list_append");
610 inline const PrimitivePtr kPrimListLen = std::make_shared<Primitive>("list_len");
611 
612 // Other miscellaneous
613 inline const PrimitivePtr kPrimEnvSetItem = std::make_shared<Primitive>("env_setitem");
614 inline const PrimitivePtr kPrimEnvGetItem = std::make_shared<Primitive>("env_getitem");
615 inline const PrimitivePtr kPrimEnvAdd = std::make_shared<Primitive>("env_add");
616 inline const PrimitivePtr kPrimMakeRefKey = std::make_shared<Primitive>("MakeRefKey");
617 inline const PrimitivePtr kPrimGetRefKey = std::make_shared<Primitive>("get_ref_key");
618 inline const PrimitivePtr kPrimMakeRef = std::make_shared<Primitive>("make_ref");
619 inline const PrimitivePtr kPrimGetRefValue = std::make_shared<Primitive>("get_ref_value");
620 
621 // Python interpreter runner
622 inline const PrimitivePtr kPrimPyInterpret = std::make_shared<Primitive>("PyInterpret");
623 
624 // Other primitive not used by backend but used in core;
625 inline const PrimitivePtr kPrimStateSetItem = std::make_shared<Primitive>("state_setitem");
626 inline const PrimitivePtr kPrimJ = std::make_shared<Primitive>("J", kSideEffectPropagate);
627 
628 // Used to build graph which have keyword arguments
629 inline const PrimitivePtr kPrimExtractKeywordArg = std::make_shared<Primitive>("extract_keyword_arg");
630 inline const PrimitivePtr kPrimMakeDict = std::make_shared<Primitive>("make_dict");
631 
632 // GraphKernel ops
633 inline const PrimitivePtr kPrimInplaceAssign = std::make_shared<Primitive>("InplaceAssign");
634 
635 // Only used in lite
636 inline const PrimitivePtr kPrimLeakyRelu = std::make_shared<Primitive>("LeakyRelu");
637 inline const PrimitivePtr kPrimConstant = std::make_shared<Primitive>("Constant");
638 inline const PrimitivePtr kPrimLocalResponseNormalization = std::make_shared<Primitive>("LocalResponseNormalization");
639 inline const PrimitivePtr kPrimFftReal = std::make_shared<Primitive>("FftReal");
640 inline const PrimitivePtr kPrimMfcc = std::make_shared<Primitive>("Mfcc");
641 inline const PrimitivePtr kPrimRfft = std::make_shared<Primitive>("Rfft");
642 inline const PrimitivePtr kPrimFftImag = std::make_shared<Primitive>("FftImag");
643 inline const PrimitivePtr kPrimSkipGram = std::make_shared<Primitive>("SkipGram");
644 inline const PrimitivePtr kPrimConv2DFusion = std::make_shared<Primitive>("Conv2DFusion");
645 inline const PrimitivePtr kPrimConv2dTransposeFusion = std::make_shared<Primitive>("Conv2dTransposeFusion");
646 inline const PrimitivePtr kPrimDepthWiseConv2DFusion = std::make_shared<Primitive>("DepthWiseConv2DFusion");
647 inline const PrimitivePtr kPrimAddFusion = std::make_shared<Primitive>("AddFusion");
648 inline const PrimitivePtr kPrimScaleFusion = std::make_shared<Primitive>("ScaleFusion");
649 inline const PrimitivePtr kPrimSubFusion = std::make_shared<Primitive>("SubFusion");
650 inline const PrimitivePtr kPrimMulFusion = std::make_shared<Primitive>("MulFusion");
651 inline const PrimitivePtr kPrimSigmoid = std::make_shared<Primitive>("Sigmoid");
652 inline const PrimitivePtr kPrimSigmoidGrad = std::make_shared<Primitive>("SigmoidGrad");
653 inline const PrimitivePtr kPrimHSigmoid = std::make_shared<Primitive>("HSigmoid");
654 inline const PrimitivePtr kPrimHSigmoidGrad = std::make_shared<Primitive>("HSigmoidGrad");
655 inline const PrimitivePtr kPrimClip = std::make_shared<Primitive>("Clip");
656 inline const PrimitivePtr kPrimHardTanh = std::make_shared<Primitive>("HardTanh");
657 inline const PrimitivePtr kPrimDepthWiseConv2DTransposeFusion =
658   std::make_shared<Primitive>("DepthWiseConv2DTransposeFusion");
659 inline const PrimitivePtr kPrimArgMinFusion = std::make_shared<Primitive>("ArgMinFusion");
660 inline const PrimitivePtr kPrimArgMaxFusion = std::make_shared<Primitive>("ArgMaxFusion");
661 inline const PrimitivePtr kPrimSpaceToDepth = std::make_shared<Primitive>("SpaceToDepth");
662 inline const PrimitivePtr kPrimPadFusion = std::make_shared<Primitive>("PadFusion");
663 inline const PrimitivePtr kPrimPowFusion = std::make_shared<Primitive>("PowFusion");
664 inline const PrimitivePtr kPrimResize = std::make_shared<Primitive>("Resize");
665 inline const PrimitivePtr kPrimArgMinWithValue = std::make_shared<Primitive>("ArgMinWithValue");
666 inline const PrimitivePtr kPrimIf = std::make_shared<Primitive>("If");
667 inline const PrimitivePtr kPrimAvgPoolFusion = std::make_shared<Primitive>("AvgPoolFusion");
668 inline const PrimitivePtr kPrimMaxPoolFusion = std::make_shared<Primitive>("MaxPoolFusion");
669 inline const PrimitivePtr kPrimActivation = std::make_shared<Primitive>("Activation");
670 inline const PrimitivePtr kPrimPReLUFusion = std::make_shared<Primitive>("PReLUFusion");
671 inline const PrimitivePtr kPrimCustom = std::make_shared<Primitive>("Custom");
672 inline const PrimitivePtr kPrimTopKFusion = std::make_shared<Primitive>("TopKFusion");
673 inline const PrimitivePtr kPrimTileFusion = std::make_shared<Primitive>("TileFusion");
674 inline const PrimitivePtr kPrimReduceFusion = std::make_shared<Primitive>("ReduceFusion");
675 inline const PrimitivePtr kPrimLayerNormFusion = std::make_shared<Primitive>("LayerNormFusion");
676 inline const PrimitivePtr kPrimDType = std::make_shared<Primitive>("DType");
677 inline const PrimitivePtr kPrimDivFusion = std::make_shared<Primitive>("DivFusion");
678 inline const PrimitivePtr kPrimErf = std::make_shared<Primitive>("Erf");
679 inline const PrimitivePtr kPrimErfc = std::make_shared<Primitive>("Erfc");
680 inline const PrimitivePtr kPrimSplice = std::make_shared<Primitive>("Splice");
681 inline const PrimitivePtr kPrimAffine = std::make_shared<Primitive>("Affine");
682 
683 // Type introspection
684 inline const PrimitivePtr kPrimTypeOf = std::make_shared<Primitive>("typeof");
685 inline const PrimitivePtr kPrimHasType = std::make_shared<Primitive>("hastype");
686 
687 inline const PrimitivePtr kPrimResolve = std::make_shared<Primitive>("resolve");
688 inline const PrimitivePtr kPrimEmbed = std::make_shared<Primitive>("embed");
689 inline const PrimitivePtr kPrimRefToEmbed = std::make_shared<Primitive>("RefToEmbed");
690 inline const PrimitivePtr kPrimCreateInstance = std::make_shared<Primitive>("create_instance");
691 
692 // Other miscellaneous
693 inline const PrimitivePtr kPrimGetRefOrigin = std::make_shared<Primitive>("get_ref_origin");
694 inline const PrimitivePtr kPrimInsertGradientOf = std::make_shared<Primitive>("InsertGradientOf");
695 inline const PrimitivePtr kPrimCheckBprop = std::make_shared<Primitive>("CheckBprop");
696 inline const PrimitivePtr kPrimMixedPrecisionCast = std::make_shared<Primitive>("mixed_precision_cast");
697 inline const PrimitivePtr kPrimMakeRecord = std::make_shared<Primitive>("make_record");
698 
699 // Structures
700 inline const PrimitivePtr kPrimListMap = std::make_shared<Primitive>("list_map");
701 inline const PrimitivePtr kPrimListReduce = std::make_shared<Primitive>("list_reduce");
702 inline const PrimitivePtr kPrimTupleReversed = std::make_shared<Primitive>("tuple_reversed");
703 inline const PrimitivePtr kPrimReducedShape = std::make_shared<Primitive>("reduced_shape");
704 inline const PrimitivePtr kPrimTupleDiv = std::make_shared<Primitive>("tuple_div");
705 inline const PrimitivePtr kPrimTupleToArray = std::make_shared<Primitive>("tuple_to_array");
706 inline const PrimitivePtr kPrimShapeMul = std::make_shared<Primitive>("shape_mul");
707 inline const PrimitivePtr kPrimTupleEqual = std::make_shared<Primitive>("tuple_equal");
708 inline const PrimitivePtr kPrimListEqual = std::make_shared<Primitive>("list_equal");
709 inline const PrimitivePtr kPrimMakeRange = std::make_shared<Primitive>("make_range");
710 inline const PrimitivePtr kPrimStopGradient = std::make_shared<Primitive>("stop_gradient");
711 inline const PrimitivePtr kPrimStringEqual = std::make_shared<Primitive>("string_equal");
712 inline const PrimitivePtr kPrimStringConcat = std::make_shared<Primitive>("string_concat");
713 inline const PrimitivePtr kPrimDictLen = std::make_shared<Primitive>("dict_len");
714 inline const PrimitivePtr kPrimFakeBprop = std::make_shared<Primitive>("fake_bprop");
715 inline const PrimitivePtr kPrimBroadcastGradientArgs = std::make_shared<Primitive>("BroadcastGradientArgs");
716 inline const PrimitivePtr kPrimDynamicBroadcastGradientArgs =
717   std::make_shared<Primitive>(kDynamicBroadcastGradientArgs);
718 
719 // Random
720 inline const PrimitivePtr kPrimStandardNormal = std::make_shared<Primitive>("StandardNormal");
721 
722 class DoSignaturePrimitive : public Primitive {
723  public:
DoSignaturePrimitive(const std::string & name,const ValuePtr & function)724   explicit DoSignaturePrimitive(const std::string &name, const ValuePtr &function)
725       : Primitive("S-Prim-" + name), function_(function) {}
726 
727   ~DoSignaturePrimitive() override = default;
728 
MS_DECLARE_PARENT(DoSignaturePrimitive,Primitive)729   MS_DECLARE_PARENT(DoSignaturePrimitive, Primitive)
730 
731   const ValuePtr function() const { return function_; }
732 
733  private:
734   ValuePtr function_;
735 };
736 using DoSignaturePrimitivePtr = std::shared_ptr<DoSignaturePrimitive>;
737 }  // namespace prim
738 }  // namespace mindspore
739 
740 #endif  // MINDSPORE_CORE_BASE_CORE_OPS_H_
741