SHL 2.2.x
Loading...
Searching...
No Matches
shl_ovx.h
1/*
2 * Copyright (C) 2016-2023 T-Head Semiconductor Co., Ltd. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/* SHL version 2.2.x */
20
21#ifndef INCLUDE_SHL_OVX_H_
22#define INCLUDE_SHL_OVX_H_
23#include "csi_nn.h"
24#include "shl_utils.h"
25
26int shl_ovx_conv2d(struct csinn_tensor *input, struct csinn_tensor *output,
27 struct csinn_tensor *kernel, struct csinn_tensor *bias,
28 struct csinn_conv2d_params *params);
29
30int shl_ovx_depthwise_conv2d(struct csinn_tensor *input, struct csinn_tensor *output,
31 struct csinn_tensor *kernel, struct csinn_tensor *bias,
32 struct csinn_conv2d_params *params);
33
34int shl_ovx_group_conv2d(struct csinn_tensor *input, struct csinn_tensor *output,
35 struct csinn_tensor *kernel, struct csinn_tensor *bias,
36 struct csinn_conv2d_params *params);
37
38int shl_ovx_conv2d_relu(struct csinn_tensor *input, struct csinn_tensor *output,
39 struct csinn_tensor *kernel, struct csinn_tensor *bias,
40 struct csinn_conv2d_params *params);
41
42int shl_ovx_deconv2d(struct csinn_tensor *input, struct csinn_tensor *output,
43 struct csinn_tensor *kernel, struct csinn_tensor *bias,
44 struct csinn_conv2d_params *params);
45
46int shl_ovx_depthwise_deconv2d(struct csinn_tensor *input, struct csinn_tensor *output,
47 struct csinn_tensor *kernel, struct csinn_tensor *bias,
48 struct csinn_conv2d_params *params);
49
50int shl_ovx_fullyconnected(struct csinn_tensor *input, struct csinn_tensor *output,
51 struct csinn_tensor *weights, struct csinn_tensor *bias,
52 struct csinn_fc_params *params);
53
54int shl_ovx_fullyconnected_relu(struct csinn_tensor *input, struct csinn_tensor *output,
55 struct csinn_tensor *weights, struct csinn_tensor *bias,
56 struct csinn_fc_params *params);
57
58int shl_ovx_maxpool2d(struct csinn_tensor *input, struct csinn_tensor *output,
59 struct csinn_pool_params *params);
60
61int shl_ovx_avgpool2d(struct csinn_tensor *input, struct csinn_tensor *output,
62 struct csinn_pool_params *params);
63
64int shl_ovx_global_avgpool2d(struct csinn_tensor *input, struct csinn_tensor *output,
65 struct csinn_pool_params *params);
66
67int shl_ovx_global_maxpool2d(struct csinn_tensor *input, struct csinn_tensor *output,
68 struct csinn_pool_params *params);
69
70int shl_ovx_l2pool(struct csinn_tensor *input, struct csinn_tensor *output,
71 struct csinn_pool_params *params);
72
73int shl_ovx_pool_with_argmax(struct csinn_tensor *input, struct csinn_tensor *output,
74 struct csinn_pool_params *params);
75
76int shl_ovx_maxpool2d_locat(struct csinn_tensor *input, struct csinn_tensor *output,
77 struct csinn_pool_params *params);
78
79int shl_ovx_unpooling(struct csinn_tensor *input, struct csinn_tensor *mask,
80 struct csinn_tensor *output, struct csinn_unpooling_params *params);
81
82int shl_ovx_negative(struct csinn_tensor *input, struct csinn_tensor *output,
83 struct csinn_siso_params *params);
84
85int shl_ovx_floor(struct csinn_tensor *input, struct csinn_tensor *output,
86 struct csinn_siso_params *params);
87
88int shl_ovx_ceil(struct csinn_tensor *input, struct csinn_tensor *output,
89 struct csinn_siso_params *params);
90
91int shl_ovx_abs(struct csinn_tensor *input, struct csinn_tensor *output,
92 struct csinn_siso_params *params);
93
94int shl_ovx_exp(struct csinn_tensor *input, struct csinn_tensor *output,
95 struct csinn_siso_params *params);
96
97int shl_ovx_log(struct csinn_tensor *input, struct csinn_tensor *output,
98 struct csinn_siso_params *params);
99
100int shl_ovx_sin(struct csinn_tensor *input, struct csinn_tensor *output,
101 struct csinn_siso_params *params);
102
103int shl_ovx_tanh(struct csinn_tensor *input, struct csinn_tensor *output,
104 struct csinn_siso_params *params);
105
106int shl_ovx_sqrt(struct csinn_tensor *input, struct csinn_tensor *output,
107 struct csinn_siso_params *params);
108
109int shl_ovx_rsqrt(struct csinn_tensor *input, struct csinn_tensor *output,
110 struct csinn_siso_params *params);
111
112int shl_ovx_square(struct csinn_tensor *input, struct csinn_tensor *output,
113 struct csinn_siso_params *params);
114
115int shl_ovx_sigmoid(struct csinn_tensor *input, struct csinn_tensor *output,
116 struct csinn_sigmoid_params *params);
117
118int shl_ovx_elu(struct csinn_tensor *input, struct csinn_tensor *output,
119 struct csinn_relu_params *params);
120
121int shl_ovx_relu(struct csinn_tensor *input, struct csinn_tensor *output,
122 struct csinn_relu_params *params);
123
124int shl_ovx_relu1(struct csinn_tensor *input, struct csinn_tensor *output,
125 struct csinn_relu_params *params);
126
127int shl_ovx_relu6(struct csinn_tensor *input, struct csinn_tensor *output,
128 struct csinn_relu_params *params);
129
130int shl_ovx_relun(struct csinn_tensor *input, struct csinn_tensor *output,
131 struct csinn_relu_params *params);
132
133int shl_ovx_leaky_relu(struct csinn_tensor *input, struct csinn_tensor *output,
134 struct csinn_relu_params *params);
135
136int shl_ovx_softrelu(struct csinn_tensor *input, struct csinn_tensor *output,
137 struct csinn_relu_params *params);
138
139int shl_ovx_prelu(struct csinn_tensor *input, struct csinn_tensor *alpha,
140 struct csinn_tensor *output, struct csinn_prelu_params *params);
141
142int shl_ovx_softplus(struct csinn_tensor *input, struct csinn_tensor *output,
143 struct csinn_siso_params *params);
144
145int shl_ovx_softmax(struct csinn_tensor *input, struct csinn_tensor *output,
146 struct csinn_softmax_params *params);
147
148int shl_ovx_log_softmax(struct csinn_tensor *input, struct csinn_tensor *output,
149 struct csinn_softmax_params *params);
150
151int shl_ovx_batch_normalization(struct csinn_tensor *input, struct csinn_tensor *mean,
152 struct csinn_tensor *variance, struct csinn_tensor *gamma,
153 struct csinn_tensor *beta, struct csinn_tensor *output,
154 struct csinn_bn_params *params);
155
156int shl_ovx_l2_normalization(struct csinn_tensor *input, struct csinn_tensor *output,
157 struct csinn_l2n_params *params);
158
159int shl_ovx_lrn(struct csinn_tensor *input, struct csinn_tensor *output,
160 struct csinn_lrn_params *params);
161
162int shl_ovx_matmul(struct csinn_tensor *mat0, struct csinn_tensor *mat1,
163 struct csinn_tensor *output, struct csinn_matmul_params *params);
164
165int shl_ovx_add(struct csinn_tensor *input0, struct csinn_tensor *input1,
166 struct csinn_tensor *output, struct csinn_diso_params *params);
167
168int shl_ovx_sub(struct csinn_tensor *input0, struct csinn_tensor *input1,
169 struct csinn_tensor *output, struct csinn_diso_params *params);
170
171int shl_ovx_mul(struct csinn_tensor *input0, struct csinn_tensor *input1,
172 struct csinn_tensor *output, struct csinn_diso_params *params);
173
174int shl_ovx_div(struct csinn_tensor *input0, struct csinn_tensor *input1,
175 struct csinn_tensor *output, struct csinn_diso_params *params);
176
177int shl_ovx_floor_divide(struct csinn_tensor *input0, struct csinn_tensor *input1,
178 struct csinn_tensor *output, struct csinn_diso_params *params);
179
180int shl_ovx_maximum(struct csinn_tensor *input0, struct csinn_tensor *input1,
181 struct csinn_tensor *output, struct csinn_diso_params *params);
182
183int shl_ovx_minimum(struct csinn_tensor *input0, struct csinn_tensor *input1,
184 struct csinn_tensor *output, struct csinn_diso_params *params);
185
186int shl_ovx_power(struct csinn_tensor *input0, struct csinn_tensor *input1,
187 struct csinn_tensor *output, struct csinn_diso_params *params);
188
189int shl_ovx_greater(struct csinn_tensor *input0, struct csinn_tensor *input1,
190 struct csinn_tensor *output, struct csinn_diso_params *params);
191
192int shl_ovx_less(struct csinn_tensor *input0, struct csinn_tensor *input1,
193 struct csinn_tensor *output, struct csinn_diso_params *params);
194
195int shl_ovx_equal(struct csinn_tensor *input0, struct csinn_tensor *input1,
196 struct csinn_tensor *output, struct csinn_diso_params *params);
197
198int shl_ovx_not_equal(struct csinn_tensor *input0, struct csinn_tensor *input1,
199 struct csinn_tensor *output, struct csinn_diso_params *params);
200
201int shl_ovx_greater_equal(struct csinn_tensor *input0, struct csinn_tensor *input1,
202 struct csinn_tensor *output, struct csinn_diso_params *params);
203
204int shl_ovx_less_equal(struct csinn_tensor *input0, struct csinn_tensor *input1,
205 struct csinn_tensor *output, struct csinn_diso_params *params);
206
207int shl_ovx_select(struct csinn_tensor *condition, struct csinn_tensor *input0,
208 struct csinn_tensor *input1, struct csinn_tensor *output,
209 struct csinn_diso_params *params);
210
211int shl_ovx_and(struct csinn_tensor *input0, struct csinn_tensor *input1,
212 struct csinn_tensor *output, struct csinn_diso_params *params);
213
214int shl_ovx_or(struct csinn_tensor *input0, struct csinn_tensor *input1,
215 struct csinn_tensor *output, struct csinn_diso_params *params);
216
217int shl_ovx_pad(struct csinn_tensor *input, struct csinn_tensor *output,
218 struct csinn_pad_params *params);
219
220int shl_ovx_resize(struct csinn_tensor *input, struct csinn_tensor *output,
221 struct csinn_resize_params *params);
222
223int shl_ovx_concat(struct csinn_tensor **input, struct csinn_tensor *output,
224 struct csinn_concat_params *params);
225
226int shl_ovx_proposal(struct csinn_tensor *cls_prob, struct csinn_tensor *bbox_pred,
227 struct csinn_tensor *im_info, struct csinn_tensor *output,
228 struct csinn_proposal_params *params);
229
230int shl_ovx_psroipooling(struct csinn_tensor *data, struct csinn_tensor *rois,
231 struct csinn_tensor *output, struct csinn_psroipooling_params *params);
232
233int shl_ovx_roipool(struct csinn_tensor *data, struct csinn_tensor *rois,
234 struct csinn_tensor *output, struct csinn_roi_pool_params *params);
235
236int shl_ovx_roi_align(struct csinn_tensor *input, struct csinn_tensor *rois,
237 struct csinn_tensor *output, struct csinn_roi_align_params *params);
238
239int shl_ovx_transpose(struct csinn_tensor *input, struct csinn_tensor *output,
240 struct csinn_transpose_params *params);
241
242int shl_ovx_reshape(struct csinn_tensor *input, struct csinn_tensor *output,
243 struct csinn_reshape_params *params);
244
245int shl_ovx_reshape_tail(struct csinn_tensor *input, struct csinn_tensor *output,
246 struct csinn_reshape_params *params);
247
248int shl_ovx_shape(struct csinn_tensor *input, struct csinn_tensor *output,
249 struct csinn_shape_params *params);
250
251int shl_ovx_expand_dims_f32(struct csinn_tensor *input, struct csinn_tensor *output,
252 struct csinn_expand_dims_params *params);
253
254int shl_ovx_expand_dims_u8(struct csinn_tensor *input, struct csinn_tensor *output,
255 struct csinn_expand_dims_params *params);
256
257int shl_ovx_reverse(struct csinn_tensor *input, struct csinn_tensor *output,
258 struct csinn_reverse_params *params);
259
260int shl_ovx_flatten(struct csinn_tensor *input, struct csinn_tensor *output,
261 struct csinn_flatten_params *params);
262
263int shl_ovx_flatten_tail(struct csinn_tensor *input, struct csinn_tensor *output,
264 struct csinn_flatten_params *params);
265
266int shl_ovx_crop(struct csinn_tensor *input, struct csinn_tensor *output,
267 struct csinn_crop_params *params);
268
269int shl_ovx_slice(struct csinn_tensor *input, struct csinn_tensor *output,
270 struct csinn_slice_params *params);
271
272int shl_ovx_slice_tail(struct csinn_tensor *input, struct csinn_tensor *output,
273 struct csinn_slice_params *params);
274
275int shl_ovx_strided_slice(struct csinn_tensor *input, struct csinn_tensor *output,
276 struct csinn_strided_slice_params *params);
277
278int shl_ovx_split(struct csinn_tensor *input, struct csinn_tensor **output,
279 struct csinn_split_params *params);
280
281int shl_ovx_stack(struct csinn_tensor **inputs, struct csinn_tensor *output,
282 struct csinn_stack_params *params);
283
284int shl_ovx_tile(struct csinn_tensor *inputs, struct csinn_tensor *output,
285 struct csinn_tile_params *params);
286
287int shl_ovx_arange(struct csinn_tensor *output, struct csinn_arange_params *params);
288
289int shl_ovx_where(struct csinn_tensor *condition, struct csinn_tensor *x, struct csinn_tensor *y,
290 struct csinn_tensor *output, struct csinn_where_params *params);
291
292int shl_ovx_unstack(struct csinn_tensor *input, struct csinn_tensor **outputs,
293 struct csinn_unstack_params *params);
294
295int shl_ovx_gather(struct csinn_tensor *input, struct csinn_tensor *indices,
296 struct csinn_tensor *output, struct csinn_gather_params *params);
297
298int shl_ovx_gather_nd(struct csinn_tensor *input, struct csinn_tensor *indices,
299 struct csinn_tensor *output, struct csinn_gather_nd_params *params);
300
301int shl_ovx_squeeze(struct csinn_tensor *input, struct csinn_tensor *output,
302 struct csinn_squeeze_params *params);
303
304int shl_ovx_squeeze_tail(struct csinn_tensor *input, struct csinn_tensor *output,
305 struct csinn_squeeze_params *params);
306
307int shl_ovx_ndarray_size(struct csinn_tensor *input, struct csinn_tensor *output,
308 struct csinn_ndarray_size_params *params);
309
310int shl_ovx_space_to_batch(struct csinn_tensor *input, struct csinn_tensor *output,
311 struct csinn_space_to_batch_params *params);
312
313int shl_ovx_batch_to_space(struct csinn_tensor *input, struct csinn_tensor *output,
314 struct csinn_batch_to_space_params *params);
315
316int shl_ovx_space_to_depth(struct csinn_tensor *input, struct csinn_tensor *output,
317 struct csinn_space_to_depth_params *params);
318
319int shl_ovx_depth_to_space(struct csinn_tensor *input, struct csinn_tensor *output,
320 struct csinn_depth_to_space_params *params);
321
322int shl_ovx_one_hot(struct csinn_tensor *input, struct csinn_tensor *output,
323 struct csinn_one_hot_params *params);
324
325int shl_ovx_sequence_mask(struct csinn_tensor *input0, struct csinn_tensor *input1,
326 struct csinn_tensor *output, struct csinn_sequence_mask_params *params);
327
328int shl_ovx_im2col(struct csinn_tensor *input, struct csinn_tensor *output,
329 struct csinn_tensor *kernel, struct csinn_im2col_params *params);
330
331int shl_ovx_col2im(struct csinn_tensor *input, struct csinn_tensor *output,
332 struct csinn_tensor *kernel, struct csinn_col2im_params *params);
333
334int shl_ovx_sum(struct csinn_tensor *input, struct csinn_tensor *output,
335 struct csinn_reduce_params *params);
336
337int shl_ovx_mean(struct csinn_tensor *input, struct csinn_tensor *output,
338 struct csinn_reduce_params *params);
339
340int shl_ovx_max(struct csinn_tensor *input, struct csinn_tensor *output,
341 struct csinn_reduce_params *params);
342
343int shl_ovx_min(struct csinn_tensor *input, struct csinn_tensor *output,
344 struct csinn_reduce_params *params);
345
346int shl_ovx_prod(struct csinn_tensor *input, struct csinn_tensor *output,
347 struct csinn_reduce_params *params);
348
349int shl_ovx_argmin(struct csinn_tensor *input, struct csinn_tensor *output,
350 struct csinn_reduce_params *params);
351
352int shl_ovx_argmax(struct csinn_tensor *input, struct csinn_tensor *output,
353 struct csinn_reduce_params *params);
354
355int shl_ovx_all(struct csinn_tensor *input, struct csinn_tensor *output,
356 struct csinn_reduce_params *params);
357
358int shl_ovx_any(struct csinn_tensor *input, struct csinn_tensor *output,
359 struct csinn_reduce_params *params);
360
361int shl_ovx_reorg(struct csinn_tensor *input, struct csinn_tensor *output,
362 struct csinn_reorg_params *params);
363
364int shl_ovx_topk(struct csinn_tensor *input, struct csinn_tensor *output0,
365 struct csinn_tensor *output1, struct csinn_topk_params *params);
366
367int shl_ovx_clip(struct csinn_tensor *input, struct csinn_tensor *output,
368 struct csinn_clip_params *params);
369
370int shl_ovx_shuffle_channel(struct csinn_tensor *input, struct csinn_tensor *output,
371 struct csinn_shuffle_channel_params *params);
372
373int32_t shl_get_ceil_mode_fix(int32_t input, int32_t kernel, int32_t stride, int32_t pad);
374
375struct shl_ovx_target_data {
376 void *graph;
377};
378
379void *shl_ovx_get_graph(struct csinn_session *sess);
380
381uint8_t *shl_ovx_input_f32_to_u8(uint32_t idx, float *data, struct csinn_session *sess);
382int shl_ovx_get_tensor(int index, struct csinn_tensor *ret, struct csinn_session *sess);
383void shl_ovx_save_output(int index, const char *filename, struct csinn_session *sess);
384void shl_ovx_show_top5(int index, struct csinn_session *sess);
385void shl_ovx_set_graph_attribute(struct csinn_session *sess, int device_index);
386int shl_ovx_get_device_number();
387int shl_ovx_set_tensor(struct csinn_tensor *tensor, struct csinn_session *sess);
388
389#endif // INCLUDE_SHL_OVX_H_
Definition: csinn_data_structure.h:893
Definition: csinn_data_structure.h:959
Definition: csinn_data_structure.h:705
Definition: csinn_data_structure.h:1081
Definition: csinn_data_structure.h:1024
Definition: csinn_data_structure.h:780
Definition: csinn_data_structure.h:553
Definition: csinn_data_structure.h:854
Definition: csinn_data_structure.h:984
Definition: csinn_data_structure.h:753
Definition: csinn_data_structure.h:837
Definition: csinn_data_structure.h:596
Definition: csinn_data_structure.h:849
Definition: csinn_data_structure.h:924
Definition: csinn_data_structure.h:919
Definition: csinn_data_structure.h:1011
Definition: csinn_data_structure.h:715
Definition: csinn_data_structure.h:727
Definition: csinn_data_structure.h:746
Definition: csinn_data_structure.h:936
Definition: csinn_data_structure.h:991
Definition: csinn_data_structure.h:763
Definition: csinn_data_structure.h:605
Definition: csinn_data_structure.h:686
Definition: csinn_data_structure.h:787
Definition: csinn_data_structure.h:808
Definition: csinn_data_structure.h:1033
Definition: csinn_data_structure.h:676
Definition: csinn_data_structure.h:1047
Definition: csinn_data_structure.h:825
Definition: csinn_data_structure.h:773
Definition: csinn_data_structure.h:843
Definition: csinn_data_structure.h:636
Definition: csinn_data_structure.h:649
Definition: csinn_data_structure.h:1002
Definition: csinn_data_structure.h:502
Definition: csinn_data_structure.h:832
Definition: csinn_data_structure.h:1097
Definition: csinn_data_structure.h:671
Definition: csinn_data_structure.h:661
Definition: csinn_data_structure.h:862
Definition: csinn_data_structure.h:692
Definition: csinn_data_structure.h:941
Definition: csinn_data_structure.h:978
Definition: csinn_data_structure.h:871
Definition: csinn_data_structure.h:929
Definition: csinn_data_structure.h:879
Definition: csinn_data_structure.h:1088
Definition: csinn_data_structure.h:475
Definition: csinn_data_structure.h:886
Definition: csinn_data_structure.h:1103
Definition: csinn_data_structure.h:818
Definition: csinn_data_structure.h:627
Definition: csinn_data_structure.h:912
Definition: csinn_data_structure.h:907