SHL 2.2.x
Loading...
Searching...
No Matches
shl_thead_rvm.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_THEAD_RVM_H_
22#define INCLUDE_SHL_THEAD_RVM_H_
23
24#include "shl_thead_rvv.h"
25
26#ifdef __riscv_xtheadmatrix
27#include <riscv_matrix.h>
28#define MATRIX_PW_I32 // requantize inst: enable
29#endif // __riscv_xtheadmatrix
30
31int shl_rvm_conv2d_init_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
32 struct csinn_tensor *kernel, struct csinn_tensor *bias,
33 struct csinn_conv2d_params *params);
34int shl_rvm_conv2d_init_int8(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_rvm_depthwise_conv2d_init_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
39 struct csinn_tensor *kernel, struct csinn_tensor *bias,
40 struct csinn_conv2d_params *params);
41int shl_rvm_depthwise_conv2d_init_int8(struct csinn_tensor *input, struct csinn_tensor *output,
42 struct csinn_tensor *kernel, struct csinn_tensor *bias,
43 struct csinn_conv2d_params *params);
44
45int shl_rvm_avgpool2d_init_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
46 struct csinn_pool_params *params);
47int shl_rvm_avgpool2d_init_int8(struct csinn_tensor *input, struct csinn_tensor *output,
48 struct csinn_pool_params *params);
49int shl_rvm_global_avgpool2d_init(struct csinn_tensor *input, struct csinn_tensor *output,
50 struct csinn_pool_params *params);
51int shl_rvm_maxpool2d_init_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
52 struct csinn_pool_params *params);
53int shl_rvm_maxpool2d_init_int8(struct csinn_tensor *input, struct csinn_tensor *output,
54 struct csinn_pool_params *params);
55
56int shl_rvm_global_maxpool2d_init(struct csinn_tensor *input, struct csinn_tensor *output,
57 struct csinn_pool_params *params);
58
59void shl_rvm_conv1x1s1_gemm_reorder_kernel_int8(struct csinn_tensor *kernel,
60 struct csinn_conv2d_params *params);
61int shl_rvm_conv1x1s1_gemm_int8(struct csinn_tensor *input, struct csinn_tensor *output,
62 struct csinn_tensor *kernel, struct csinn_tensor *bias,
63 struct csinn_conv2d_params *params);
64int shl_rvm_group_conv1x1s1_gemm_int8(struct csinn_tensor *input, struct csinn_tensor *output,
65 struct csinn_tensor *kernel, struct csinn_tensor *bias,
66 struct csinn_conv2d_params *params);
67
68void shl_rvm_conv_im2col_gemm_reorder_kernel_int8(struct csinn_tensor *kernel,
69 struct csinn_conv2d_params *params);
70int shl_rvm_conv_im2col_gemm_int8(struct csinn_tensor *input, struct csinn_tensor *output,
71 struct csinn_tensor *kernel, struct csinn_tensor *bias,
72 struct csinn_conv2d_params *params);
73int shl_rvm_group_conv_im2col_gemm_int8(struct csinn_tensor *input, struct csinn_tensor *output,
74 struct csinn_tensor *kernel, struct csinn_tensor *bias,
75 struct csinn_conv2d_params *params);
76
77void shl_rvm_conv1x1s1_gemm_reorder_kernel_fp16(struct csinn_tensor *kernel,
78 struct csinn_conv2d_params *params);
79int shl_rvm_conv1x1s1_gemm_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
80 struct csinn_tensor *kernel, struct csinn_tensor *bias,
81 struct csinn_conv2d_params *params);
82int shl_rvm_group_conv1x1s1_gemm_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
83 struct csinn_tensor *kernel, struct csinn_tensor *bias,
84 struct csinn_conv2d_params *params);
85
86void shl_rvm_conv_im2col_gemm_reorder_kernel_fp16(struct csinn_tensor *kernel,
87 struct csinn_conv2d_params *params);
88int shl_rvm_conv_im2col_gemm_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
89 struct csinn_tensor *kernel, struct csinn_tensor *bias,
90 struct csinn_conv2d_params *params);
91int shl_rvm_group_conv_im2col_gemm_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
92 struct csinn_tensor *kernel, struct csinn_tensor *bias,
93 struct csinn_conv2d_params *params);
94
95void shl_rvm_nhwc_gemm_int8(int8_t *dst, const int8_t *sa, const int8_t *sb, const int32_t *bias,
96 int m, int k, int n, int32_t out_zp, int32_t *mult, int32_t *shift);
97void shl_rvm_nhwc_gemm_fp16(__fp16 *dst, const __fp16 *sa, const __fp16 *sb, const __fp16 *bias,
98 int m, int k, int n);
99void shl_rvm_nhwc_gemm_fp16_intrinsic(__fp16 *dst, const __fp16 *sa, const __fp16 *sb,
100 const __fp16 *bias, int m, int k, int n);
101
102void shl_rvm_wg_b4f3s1_trans_kernel_nhwc_fp16(struct csinn_tensor *src_kernel,
103 struct csinn_tensor *dst_kernel);
104int shl_rvm_wg_b4f3s1_nhwc_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
105 struct csinn_tensor *kernel, struct csinn_tensor *bias,
106 struct csinn_conv2d_params *params);
107void shl_rvm_wg_b6f3s1_trans_kernel_nhwc_fp16(struct csinn_tensor *src_kernel,
108 struct csinn_tensor *dst_kernel);
109int shl_rvm_wg_b6f3s1_nhwc_fp16(struct csinn_tensor *input, struct csinn_tensor *output,
110 struct csinn_tensor *kernel, struct csinn_tensor *bias,
111 struct csinn_conv2d_params *params);
112
113int csrr_xrlenb();
114
115#endif // INCLUDE_SHL_THEAD_RVM_H_
Definition: csinn_data_structure.h:553
Definition: csinn_data_structure.h:605
Definition: csinn_data_structure.h:475