• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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_NNACL_MATMUL_H_
18 #define MINDSPORE_NNACL_MATMUL_H_
19 
20 #include "nnacl/op_base.h"
21 
22 typedef void (*MATMUL_OPT_R4_FUNC)(const int8_t *a, const int8_t *b, int *dst, int row_4, int col_4, int deep_16,
23                                    const int *input_sum, const int *bias);
24 
25 typedef void (*MATMUL_OPT_R_FUNC)(const int8_t *a, const int8_t *b, int8_t *dst, size_t row, size_t col, size_t deep_4,
26                                   size_t stride, const int32_t *input_sum, const int32_t *bias,
27                                   const int32_t *left_shift, const int32_t *right_shift, const int32_t *multiplier,
28                                   int32_t output_zp, int32_t mini, int32_t maxi, size_t per_channel);
29 
30 typedef void (*MATMUL_OPT_DP_FUNC)(const int8_t *a, const int8_t *b, int8_t *dst, size_t row, size_t col, size_t deep_4,
31                                    size_t stride, const int32_t *input_sum, const int32_t *bias,
32                                    const int32_t *left_shift, const int32_t *right_shift, const int32_t *multiplier,
33                                    int32_t output_zp, int32_t mini, int32_t maxi, size_t per_channel,
34                                    const int *filter_zp);
35 
36 typedef enum OutType { OutType_C8 = 0, OutType_Nhwc = 1, OutType_TileC8 = 2, OutType_NC4HW4 = 3 } OutType;
37 
38 typedef struct MatMulParameter {
39   // Primitive parameter
40   OpParameter op_parameter_;
41   bool has_bias_;
42 
43   // other parameter
44   int row_;
45   int col_;
46   int row_4_;
47   int row_6_;
48   int row_12_;
49   int row_16_;
50   int row_align_;
51   int col_4_;
52   int col_8_;
53   int col_align_;
54   int deep_;
55   int deep_4_;
56   int deep_16_;
57   int batch;
58   bool a_transpose_; /* false :  row-major  */
59   bool b_transpose_; /* true  :  col-major  */
60   bool a_const_;
61   bool b_const_;
62   ActType act_type_;
63   bool use_axis_;
64   int axis_;
65 } MatMulParameter;
66 
67 typedef struct MatmulQuantParameter {
68   QuantArg input_;
69   QuantArg weight_;
70   QuantArg output_;
71   int32_t out_act_min_;
72   int32_t out_act_max_;
73   float *filter_scale_;
74   int32_t *filter_zp_;
75   int32_t *left_shift_;
76   int32_t *right_shift_;
77   int32_t *quant_multiplier_;
78 } MatmulQuantParameter;
79 
80 #endif  // MINDSPORE_NNACL_MATMUL_H_
81