• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 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 #include "nnacl/kernel/init_vs_kernels.h"
18 #include "nnacl/kernel/activation.h"
19 #include "nnacl/kernel/arithmetic.h"
20 #include "nnacl/kernel/arithmetic_compare.h"
21 #include "nnacl/kernel/arithmetic_self.h"
22 #include "nnacl/kernel/arg_min_max.h"
23 #include "nnacl/kernel/addn.h"
24 #include "nnacl/kernel/biasadd.h"
25 #include "nnacl/kernel/batch_norm.h"
26 #include "nnacl/kernel/clip.h"
27 #include "nnacl/kernel/concat.h"
28 #include "nnacl/kernel/crop.h"
29 #include "nnacl/kernel/crop_and_resize.h"
30 #include "nnacl/kernel/exp.h"
31 #include "nnacl/kernel/depth_to_space.h"
32 #include "nnacl/kernel/fill.h"
33 #include "nnacl/kernel/fused_batch_norm.h"
34 #include "nnacl/kernel/fullconnection.h"
35 #include "nnacl/kernel/gather.h"
36 #include "nnacl/kernel/gather_d.h"
37 #include "nnacl/kernel/gather_nd.h"
38 #include "nnacl/kernel/group_norm.h"
39 #include "nnacl/kernel/log_softmax.h"
40 #include "nnacl/kernel/local_response_norm.h"
41 #include "nnacl/kernel/layer_norm.h"
42 #include "nnacl/kernel/matmul.h"
43 #include "nnacl/kernel/non_max_suppression.h"
44 #include "nnacl/kernel/non_zero.h"
45 #include "nnacl/kernel/nllloss.h"
46 #include "nnacl/kernel/prior_box.h"
47 #include "nnacl/kernel/prelu.h"
48 #include "nnacl/kernel/pad.h"
49 #include "nnacl/kernel/pow.h"
50 #include "nnacl/kernel/reshape.h"
51 #include "nnacl/kernel/reverse.h"
52 #include "nnacl/kernel/range.h"
53 #include "nnacl/kernel/rank.h"
54 #include "nnacl/kernel/scale.h"
55 #include "nnacl/kernel/shape.h"
56 #include "nnacl/kernel/reduce.h"
57 #include "nnacl/kernel/ragged_range.h"
58 #include "nnacl/kernel/stack.h"
59 #include "nnacl/kernel/strided_slice.h"
60 #include "nnacl/kernel/softmax.h"
61 #include "nnacl/kernel/size.h"
62 #include "nnacl/kernel/splice.h"
63 #include "nnacl/kernel/tile.h"
64 #include "nnacl/kernel/tril.h"
65 #include "nnacl/kernel/triu.h"
66 #include "nnacl/kernel/transpose.h"
67 #include "nnacl/kernel/slice.h"
68 #include "nnacl/kernel/unique.h"
69 #ifdef ENABLE_FP16
70 #include "nnacl/kernel/f16/arithmetic_f16.h"
71 #include "nnacl/kernel/f16/arithmetic_compare_f16.h"
72 #include "nnacl/kernel/f16/concat_f16.h"
73 #include "nnacl/kernel/f16/reduce_f16.h"
74 #include "nnacl/kernel/f16/stack_f16.h"
75 #endif
76 
InitVSKernelF16(KernelCreator ** creators)77 void InitVSKernelF16(KernelCreator **creators) {
78 #ifdef ENABLE_FP16
79   creators[PrimType_Abs][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
80   creators[PrimType_Activation][REGIST_DT(kNumberTypeFloat16)] = CreateActivation;
81   creators[PrimType_AddFusion][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
82   creators[PrimType_AddN][REGIST_DT(kNumberTypeFloat16)] = CreateAddN;
83   creators[PrimType_ArgMinFusion][REGIST_DT(kNumberTypeFloat16)] = CreateArgMinMax;
84   creators[PrimType_ArgMaxFusion][REGIST_DT(kNumberTypeFloat16)] = CreateArgMinMax;
85   creators[PrimType_BatchNorm][REGIST_DT(kNumberTypeFloat16)] = CreateBatchNorm;
86   creators[PrimType_Ceil][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
87   creators[PrimType_Concat][REGIST_DT(kNumberTypeFloat16)] = CreateConcatF16;
88   creators[PrimType_Cos][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
89   creators[PrimType_Crop][REGIST_DT(kNumberTypeFloat16)] = CreateCrop;
90   creators[PrimType_DivFusion][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
91   creators[PrimType_DepthToSpace][REGIST_DT(kNumberTypeFloat16)] = CreateDepthToSpace;
92   creators[PrimType_Eltwise][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
93   creators[PrimType_Erf][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
94   creators[PrimType_Equal][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticCompareF16;
95   creators[PrimType_ExpandDims][REGIST_DT(kNumberTypeFloat16)] = CreateReshape;
96   creators[PrimType_Fill][REGIST_DT(kNumberTypeFloat16)] = CreateFill;
97   creators[PrimType_Flatten][REGIST_DT(kNumberTypeFloat16)] = CreateReshape;
98   creators[PrimType_FlattenGrad][REGIST_DT(kNumberTypeFloat16)] = CreateReshape;
99   creators[PrimType_Floor][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
100   creators[PrimType_FloorMod][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
101   creators[PrimType_FloorDiv][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
102   creators[PrimType_FusedBatchNorm][REGIST_DT(kNumberTypeFloat16)] = CreateFusedBatchNorm;
103   creators[PrimType_Gather][REGIST_DT(kNumberTypeFloat16)] = CreateGather;
104   creators[PrimType_GatherD][REGIST_DT(kNumberTypeFloat16)] = CreateGatherD;
105   creators[PrimType_GatherNd][REGIST_DT(kNumberTypeFloat16)] = CreateGatherNd;
106   creators[PrimType_Greater][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticCompareF16;
107   creators[PrimType_GreaterEqual][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticCompareF16;
108   creators[PrimType_Less][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticCompareF16;
109   creators[PrimType_LessEqual][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticCompareF16;
110   creators[PrimType_LayerNormFusion][REGIST_DT(kNumberTypeFloat16)] = CreateLayerNorm;
111   creators[PrimType_LogicalAnd][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
112   creators[PrimType_LogicalOr][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
113   creators[PrimType_Log][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
114   creators[PrimType_LogSoftmax][REGIST_DT(kNumberTypeFloat16)] = CreateLogSoftmax;
115   creators[PrimType_LogicalNot][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
116   creators[PrimType_Maximum][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
117   creators[PrimType_Minimum][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
118   creators[PrimType_MulFusion][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
119   creators[PrimType_Neg][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
120   creators[PrimType_NotEqual][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticCompareF16;
121   creators[PrimType_PadFusion][REGIST_DT(kNumberTypeFloat16)] = CreatePad;
122   creators[PrimType_PReLUFusion][REGIST_DT(kNumberTypeFloat16)] = CreatePRelu;
123   creators[PrimType_PowFusion][REGIST_DT(kNumberTypeFloat16)] = CreatePow;
124   creators[PrimType_Reshape][REGIST_DT(kNumberTypeFloat16)] = CreateReshape;
125   creators[PrimType_RealDiv][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
126   creators[PrimType_ReduceFusion][REGIST_DT(kNumberTypeFloat16)] = CreateReduceF16;
127   creators[PrimType_Rsqrt][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
128   creators[PrimType_Round][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
129   creators[PrimType_Reciprocal][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
130   creators[PrimType_ScaleFusion][REGIST_DT(kNumberTypeFloat16)] = CreateScale;
131   creators[PrimType_Shape][REGIST_DT(kNumberTypeFloat16)] = CreateShape;
132   creators[PrimType_Softmax][REGIST_DT(kNumberTypeFloat16)] = CreateSoftmax;
133   creators[PrimType_Stack][REGIST_DT(kNumberTypeFloat16)] = CreateStackF16;
134   creators[PrimType_StridedSlice][REGIST_DT(kNumberTypeFloat16)] = CreateStridedSlice;
135   creators[PrimType_Squeeze][REGIST_DT(kNumberTypeFloat16)] = CreateReshape;
136   creators[PrimType_SubFusion][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
137   creators[PrimType_SquaredDifference][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticF16;
138   creators[PrimType_Splice][REGIST_DT(kNumberTypeFloat16)] = CreateSplice;
139   creators[PrimType_Sin][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
140   creators[PrimType_Size][REGIST_DT(kNumberTypeFloat16)] = CreateSize;
141   creators[PrimType_SliceFusion][REGIST_DT(kNumberTypeFloat16)] = CreateSlice;
142   creators[PrimType_Square][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
143   creators[PrimType_Sqrt][REGIST_DT(kNumberTypeFloat16)] = CreateArithmeticSelf;
144   creators[PrimType_TileFusion][REGIST_DT(kNumberTypeFloat16)] = CreateTile;
145   creators[PrimType_Triu][REGIST_DT(kNumberTypeFloat16)] = CreateTriu;
146   creators[PrimType_Tril][REGIST_DT(kNumberTypeFloat16)] = CreateTril;
147   creators[PrimType_Transpose][REGIST_DT(kNumberTypeFloat16)] = CreateTranspose;
148   creators[PrimType_Unsqueeze][REGIST_DT(kNumberTypeFloat16)] = CreateReshape;
149   creators[PrimType_Unique][REGIST_DT(kNumberTypeFloat16)] = CreateUnique;
150 #endif
151 }
152 
InitVSKernelA(KernelCreator ** creators)153 void InitVSKernelA(KernelCreator **creators) {
154   creators[PrimType_Abs][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
155   creators[PrimType_Abs][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticSelf;
156   creators[PrimType_Activation][REGIST_DT(kNumberTypeFloat32)] = CreateActivation;
157   creators[PrimType_Activation][REGIST_DT(kNumberTypeUInt32)] = CreateActivation;
158   creators[PrimType_AddFusion][REGIST_DT(kNumberTypeBool)] = CreateArithmetic;
159   creators[PrimType_AddFusion][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
160   creators[PrimType_AddFusion][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
161   creators[PrimType_AddN][REGIST_DT(kNumberTypeFloat32)] = CreateAddN;
162   creators[PrimType_ArgMinFusion][REGIST_DT(kNumberTypeInt32)] = CreateArgMinMax;
163   creators[PrimType_ArgMinFusion][REGIST_DT(kNumberTypeFloat32)] = CreateArgMinMax;
164   creators[PrimType_ArgMaxFusion][REGIST_DT(kNumberTypeInt32)] = CreateArgMinMax;
165   creators[PrimType_ArgMaxFusion][REGIST_DT(kNumberTypeFloat32)] = CreateArgMinMax;
166   creators[PrimType_BiasAdd][REGIST_DT(kNumberTypeFloat32)] = CreateBiasAdd;
167   creators[PrimType_BatchNorm][REGIST_DT(kNumberTypeFloat32)] = CreateBatchNorm;
168   creators[PrimType_Ceil][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
169   creators[PrimType_Cos][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
170   creators[PrimType_Clip][REGIST_DT(kNumberTypeFloat)] = CreateClip;
171   creators[PrimType_Clip][REGIST_DT(kNumberTypeFloat32)] = CreateClip;
172   creators[PrimType_Clip][REGIST_DT(kNumberTypeInt)] = CreateClip;
173   creators[PrimType_Clip][REGIST_DT(kNumberTypeInt32)] = CreateClip;
174   creators[PrimType_Concat][REGIST_DT(kNumberTypeBool)] = CreateConcat;
175   creators[PrimType_Concat][REGIST_DT(kNumberTypeInt32)] = CreateConcat;
176   creators[PrimType_Concat][REGIST_DT(kNumberTypeFloat32)] = CreateConcat;
177   creators[PrimType_Crop][REGIST_DT(kNumberTypeInt32)] = CreateCrop;
178   creators[PrimType_Crop][REGIST_DT(kNumberTypeFloat32)] = CreateCrop;
179   creators[PrimType_CropAndResize][REGIST_DT(kNumberTypeFloat32)] = CreateCropAndResize;
180   creators[PrimType_DepthToSpace][REGIST_DT(kNumberTypeFloat32)] = CreateDepthToSpace;
181   creators[PrimType_DivFusion][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
182   creators[PrimType_DivFusion][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
183   creators[PrimType_Eltwise][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
184   creators[PrimType_Equal][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticCompare;
185   creators[PrimType_Equal][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticCompare;
186   creators[PrimType_Erf][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
187   creators[PrimType_ExpFusion][REGIST_DT(kNumberTypeFloat32)] = CreateExp;
188   creators[PrimType_ExpandDims][REGIST_DT(kNumberTypeInt32)] = CreateReshape;
189   creators[PrimType_ExpandDims][REGIST_DT(kNumberTypeFloat32)] = CreateReshape;
190   creators[PrimType_ExpandDims][REGIST_DT(kNumberTypeBool)] = CreateReshape;
191   creators[PrimType_ExpandDims][REGIST_DT(kNumberTypeInt8)] = CreateReshape;
192   creators[PrimType_Fill][REGIST_DT(kNumberTypeBool)] = CreateFill;
193   creators[PrimType_Fill][REGIST_DT(kNumberTypeInt32)] = CreateFill;
194   creators[PrimType_Fill][REGIST_DT(kNumberTypeFloat32)] = CreateFill;
195   creators[PrimType_Flatten][REGIST_DT(kNumberTypeInt32)] = CreateReshape;
196   creators[PrimType_Flatten][REGIST_DT(kNumberTypeFloat32)] = CreateReshape;
197   creators[PrimType_FlattenGrad][REGIST_DT(kNumberTypeFloat32)] = CreateReshape;
198   creators[PrimType_Floor][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
199   creators[PrimType_FloorDiv][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
200   creators[PrimType_FloorDiv][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
201   creators[PrimType_FloorMod][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
202   creators[PrimType_FloorMod][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
203   creators[PrimType_FullConnection][REGIST_DT(kNumberTypeFloat32)] = CreateFullconnection;
204   creators[PrimType_FusedBatchNorm][REGIST_DT(kNumberTypeFloat32)] = CreateFusedBatchNorm;
205   creators[PrimType_Gather][REGIST_DT(kNumberTypeFloat32)] = CreateGather;
206   creators[PrimType_Gather][REGIST_DT(kNumberTypeInt32)] = CreateGather;
207   creators[PrimType_Gather][REGIST_DT(kNumberTypeBool)] = CreateGather;
208   creators[PrimType_GatherD][REGIST_DT(kNumberTypeFloat32)] = CreateGatherD;
209   creators[PrimType_GatherD][REGIST_DT(kNumberTypeInt32)] = CreateGatherD;
210   creators[PrimType_GatherNd][REGIST_DT(kNumberTypeBool)] = CreateGatherNd;
211   creators[PrimType_GatherNd][REGIST_DT(kNumberTypeInt32)] = CreateGatherNd;
212   creators[PrimType_GatherNd][REGIST_DT(kNumberTypeFloat32)] = CreateGatherNd;
213   creators[PrimType_Greater][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticCompare;
214   creators[PrimType_Greater][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticCompare;
215   creators[PrimType_GreaterEqual][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticCompare;
216   creators[PrimType_GreaterEqual][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticCompare;
217   creators[PrimType_GroupNormFusion][REGIST_DT(kNumberTypeFloat32)] = CreateGroupNorm;
218 }
219 
InitVSKernelI(KernelCreator ** creators)220 void InitVSKernelI(KernelCreator **creators) {
221   creators[PrimType_IsFinite][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
222   creators[PrimType_LayerNormFusion][REGIST_DT(kNumberTypeFloat32)] = CreateLayerNorm;
223   creators[PrimType_Less][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticCompare;
224   creators[PrimType_Less][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticCompare;
225   creators[PrimType_LessEqual][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticCompare;
226   creators[PrimType_LessEqual][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticCompare;
227   creators[PrimType_LogicalAnd][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
228   creators[PrimType_LogicalAnd][REGIST_DT(kNumberTypeBool)] = CreateArithmetic;
229   creators[PrimType_LogicalAnd][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
230   creators[PrimType_LogicalOr][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
231   creators[PrimType_LogicalOr][REGIST_DT(kNumberTypeBool)] = CreateArithmetic;
232   creators[PrimType_Log][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
233   creators[PrimType_LogSoftmax][REGIST_DT(kNumberTypeFloat32)] = CreateLogSoftmax;
234   creators[PrimType_Log1p][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
235   creators[PrimType_LogicalNot][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
236   creators[PrimType_LogicalNot][REGIST_DT(kNumberTypeBool)] = CreateArithmeticSelf;
237   creators[PrimType_LRN][REGIST_DT(kNumberTypeFloat32)] = CreateLocalResponseNorm;
238   creators[PrimType_Maximum][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
239   creators[PrimType_Maximum][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
240   creators[PrimType_MatMulFusion][REGIST_DT(kNumberTypeFloat32)] = CreateMatmul;
241   creators[PrimType_Mod][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
242   creators[PrimType_Mod][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
243   creators[PrimType_MulFusion][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
244   creators[PrimType_MulFusion][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
245   creators[PrimType_Minimum][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
246   creators[PrimType_Minimum][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
247   creators[PrimType_NLLLoss][REGIST_DT(kNumberTypeFloat32)] = CreateNLLLoss;
248   creators[PrimType_Neg][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
249   creators[PrimType_Neg][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticSelf;
250   creators[PrimType_NotEqual][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticCompare;
251   creators[PrimType_NotEqual][REGIST_DT(kNumberTypeInt32)] = CreateArithmeticCompare;
252   creators[PrimType_NotEqual][REGIST_DT(kNumberTypeInt64)] = CreateArithmeticCompare;
253   creators[PrimType_NonZero][REGIST_DT(kNumberTypeBool)] = CreateNonZero;
254   creators[PrimType_NonMaxSuppression][REGIST_DT(kNumberTypeFloat32)] = CreateNonMaxSuppression;
255   creators[PrimType_PadFusion][REGIST_DT(kNumberTypeFloat32)] = CreatePad;
256   creators[PrimType_PriorBox][REGIST_DT(kNumberTypeFloat32)] = CreatePriorBox;
257   creators[PrimType_PriorBox][REGIST_DT(kNumberTypeInt8)] = CreatePriorBox;
258   creators[PrimType_PowFusion][REGIST_DT(kNumberTypeFloat32)] = CreatePow;
259   creators[PrimType_PReLUFusion][REGIST_DT(kNumberTypeFloat32)] = CreatePRelu;
260 }
261 
InitVSKernelR(KernelCreator ** creators)262 void InitVSKernelR(KernelCreator **creators) {
263   creators[PrimType_RaggedRange][REGIST_DT(kNumberTypeInt32)] = CreateRaggedRange;
264   creators[PrimType_RaggedRange][REGIST_DT(kNumberTypeFloat32)] = CreateRaggedRange;
265   creators[PrimType_Range][REGIST_DT(kNumberTypeFloat32)] = CreateRange;
266   creators[PrimType_Range][REGIST_DT(kNumberTypeInt32)] = CreateRange;
267   creators[PrimType_Range][REGIST_DT(kNumberTypeFloat16)] = CreateRange;
268   creators[PrimType_Rank][REGIST_DT(kNumberTypeFloat32)] = CreateRank;
269   creators[PrimType_Rank][REGIST_DT(kNumberTypeFloat32)] = CreateRank;
270   creators[PrimType_Reshape][REGIST_DT(kNumberTypeInt32)] = CreateReshape;
271   creators[PrimType_Reshape][REGIST_DT(kNumberTypeFloat32)] = CreateReshape;
272   creators[PrimType_Reshape][REGIST_DT(kNumberTypeBool)] = CreateReshape;
273   creators[PrimType_RealDiv][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
274   creators[PrimType_ReduceFusion][REGIST_DT(kNumberTypeBool)] = CreateReduce;
275   creators[PrimType_ReduceFusion][REGIST_DT(kNumberTypeInt32)] = CreateReduce;
276   creators[PrimType_ReduceFusion][REGIST_DT(kNumberTypeFloat32)] = CreateReduce;
277   creators[PrimType_Reciprocal][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
278   creators[PrimType_ReverseV2][REGIST_DT(kNumberTypeInt32)] = CreateReverse;
279   creators[PrimType_ReverseV2][REGIST_DT(kNumberTypeFloat32)] = CreateReverse;
280   creators[PrimType_Round][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
281   creators[PrimType_Rsqrt][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
282   creators[PrimType_ScaleFusion][REGIST_DT(kNumberTypeFloat32)] = CreateScale;
283   creators[PrimType_Shape][REGIST_DT(kNumberTypeInt32)] = CreateShape;
284   creators[PrimType_Shape][REGIST_DT(kNumberTypeBool)] = CreateShape;
285   creators[PrimType_Shape][REGIST_DT(kNumberTypeFloat32)] = CreateShape;
286   creators[PrimType_Shape][REGIST_DT(kNumberTypeInt8)] = CreateShape;
287   creators[PrimType_Shape][REGIST_DT(kNumberTypeUInt8)] = CreateShape;
288   creators[PrimType_Shape][REGIST_DT(kNumberTypeInt64)] = CreateShape;
289   creators[PrimType_Softmax][REGIST_DT(kNumberTypeFloat32)] = CreateSoftmax;
290   creators[PrimType_SquaredDifference][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
291   creators[PrimType_Stack][REGIST_DT(kNumberTypeFloat32)] = CreateStack;
292   creators[PrimType_Stack][REGIST_DT(kNumberTypeInt32)] = CreateStack;
293   creators[PrimType_StridedSlice][REGIST_DT(kNumberTypeFloat32)] = CreateStridedSlice;
294   creators[PrimType_StridedSlice][REGIST_DT(kNumberTypeInt64)] = CreateStridedSlice;
295   creators[PrimType_StridedSlice][REGIST_DT(kNumberTypeInt32)] = CreateStridedSlice;
296   creators[PrimType_StridedSlice][REGIST_DT(kNumberTypeInt8)] = CreateStridedSlice;
297   creators[PrimType_Square][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
298   creators[PrimType_Sqrt][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
299   creators[PrimType_Sin][REGIST_DT(kNumberTypeFloat32)] = CreateArithmeticSelf;
300   creators[PrimType_Size][REGIST_DT(kNumberTypeInt32)] = CreateSize;
301   creators[PrimType_Size][REGIST_DT(kNumberTypeFloat32)] = CreateSize;
302   creators[PrimType_SliceFusion][REGIST_DT(kNumberTypeInt32)] = CreateSlice;
303   creators[PrimType_SliceFusion][REGIST_DT(kNumberTypeFloat32)] = CreateSlice;
304   creators[PrimType_SubFusion][REGIST_DT(kNumberTypeFloat32)] = CreateArithmetic;
305   creators[PrimType_SubFusion][REGIST_DT(kNumberTypeInt32)] = CreateArithmetic;
306   creators[PrimType_Squeeze][REGIST_DT(kNumberTypeFloat32)] = CreateReshape;
307   creators[PrimType_Squeeze][REGIST_DT(kNumberTypeInt32)] = CreateReshape;
308   creators[PrimType_Squeeze][REGIST_DT(kNumberTypeBool)] = CreateReshape;
309   creators[PrimType_Splice][REGIST_DT(kNumberTypeFloat32)] = CreateSplice;
310   creators[PrimType_TileFusion][REGIST_DT(kNumberTypeInt32)] = CreateTile;
311   creators[PrimType_TileFusion][REGIST_DT(kNumberTypeFloat32)] = CreateTile;
312   creators[PrimType_TileFusion][REGIST_DT(kNumberTypeBool)] = CreateTile;
313   creators[PrimType_TileFusion][REGIST_DT(kNumberTypeUInt8)] = CreateTile;
314   creators[PrimType_Triu][REGIST_DT(kNumberTypeDouble)] = CreateTriu;
315   creators[PrimType_Triu][REGIST_DT(kNumberTypeFloat)] = CreateTriu;
316   creators[PrimType_Triu][REGIST_DT(kNumberTypeFloat64)] = CreateTriu;
317   creators[PrimType_Triu][REGIST_DT(kNumberTypeFloat32)] = CreateTriu;
318   creators[PrimType_Triu][REGIST_DT(kNumberTypeInt)] = CreateTriu;
319   creators[PrimType_Triu][REGIST_DT(kNumberTypeInt64)] = CreateTriu;
320   creators[PrimType_Triu][REGIST_DT(kNumberTypeInt32)] = CreateTriu;
321   creators[PrimType_Triu][REGIST_DT(kNumberTypeInt16)] = CreateTriu;
322   creators[PrimType_Triu][REGIST_DT(kNumberTypeInt8)] = CreateTriu;
323   creators[PrimType_Triu][REGIST_DT(kNumberTypeUInt64)] = CreateTriu;
324   creators[PrimType_Triu][REGIST_DT(kNumberTypeUInt32)] = CreateTriu;
325   creators[PrimType_Triu][REGIST_DT(kNumberTypeUInt16)] = CreateTriu;
326   creators[PrimType_Triu][REGIST_DT(kNumberTypeUInt8)] = CreateTriu;
327   creators[PrimType_Triu][REGIST_DT(kNumberTypeBool)] = CreateTriu;
328   creators[PrimType_Tril][REGIST_DT(kNumberTypeDouble)] = CreateTril;
329   creators[PrimType_Tril][REGIST_DT(kNumberTypeFloat)] = CreateTril;
330   creators[PrimType_Tril][REGIST_DT(kNumberTypeFloat64)] = CreateTril;
331   creators[PrimType_Tril][REGIST_DT(kNumberTypeFloat32)] = CreateTril;
332   creators[PrimType_Tril][REGIST_DT(kNumberTypeInt)] = CreateTril;
333   creators[PrimType_Tril][REGIST_DT(kNumberTypeInt64)] = CreateTril;
334   creators[PrimType_Tril][REGIST_DT(kNumberTypeInt32)] = CreateTril;
335   creators[PrimType_Tril][REGIST_DT(kNumberTypeInt16)] = CreateTril;
336   creators[PrimType_Tril][REGIST_DT(kNumberTypeInt8)] = CreateTril;
337   creators[PrimType_Tril][REGIST_DT(kNumberTypeUInt64)] = CreateTril;
338   creators[PrimType_Tril][REGIST_DT(kNumberTypeUInt32)] = CreateTril;
339   creators[PrimType_Tril][REGIST_DT(kNumberTypeUInt16)] = CreateTril;
340   creators[PrimType_Tril][REGIST_DT(kNumberTypeUInt8)] = CreateTril;
341   creators[PrimType_Tril][REGIST_DT(kNumberTypeBool)] = CreateTril;
342   creators[PrimType_Transpose][REGIST_DT(kNumberTypeFloat32)] = CreateTranspose;
343   creators[PrimType_Transpose][REGIST_DT(kNumberTypeInt32)] = CreateTranspose;
344   creators[PrimType_Unsqueeze][REGIST_DT(kNumberTypeFloat32)] = CreateReshape;
345   creators[PrimType_Unsqueeze][REGIST_DT(kNumberTypeInt32)] = CreateReshape;
346   creators[PrimType_Unsqueeze][REGIST_DT(kNumberTypeInt64)] = CreateReshape;
347   creators[PrimType_Unsqueeze][REGIST_DT(kNumberTypeBool)] = CreateReshape;
348   creators[PrimType_Unique][REGIST_DT(kNumberTypeInt32)] = CreateUnique;
349   creators[PrimType_Unique][REGIST_DT(kNumberTypeFloat32)] = CreateUnique;
350 }
351 
init_vs_kernels(KernelCreator ** creators)352 void init_vs_kernels(KernelCreator **creators) {
353   InitVSKernelA(creators);
354   InitVSKernelI(creators);
355   InitVSKernelR(creators);
356   InitVSKernelF16(creators);
357 }
358