• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 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 #ifndef MINDSPORE_LITE_MICRO_CODER_WRAPPER_FP32_ARITHMETIC_FP32_WRAPPER_H_
17 #define MINDSPORE_LITE_MICRO_CODER_WRAPPER_FP32_ARITHMETIC_FP32_WRAPPER_H_
18 #include "nnacl/fp32/arithmetic_fp32.h"
19 #include <string.h>
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 typedef enum ArithmeticFuncType {
24   kArithmeticFuncFloat = 0,
25   kArithmeticFuncBool = 1,
26   kArithmeticFuncInt = 2,
27   kArithmeticFuncUnknow = 3,
28 } ArithmeticFuncType;
29 
30 typedef struct ArithmeticWrapperInfo {
31   int offset0_;
32   int stride0_;
33   int offset1_;
34   int stride1_;
35   int out_offset_;
36   int out_stride_;
37   ArithmeticFuncType arithmetic_func_type_;
38 } ArithmeticWrapperInfo;
39 
40 typedef int (*ArithmeticRun)(const float *input0, const float *input1, float *output, const int element_size);
41 typedef int (*ArithmeticOptRun)(const float *input0, const float *input1, float *output, const int element_size,
42                                 const ArithmeticParameter *param);
43 typedef int (*ArithmeticIntRun)(const int *input0, const int *input1, int *output, const int element_size);
44 typedef int (*ArithmeticOptIntRun)(const int *input0, const int *input1, int *output, const int element_size,
45                                    const ArithmeticParameter *param);
46 typedef int (*ArithmeticBoolRun)(const bool *input0, const bool *input1, bool *output, const int element_size);
47 
48 void ArithmeticExecute(const void *input0, const void *input1, void *output, int size, bool is_opt,
49                        ArithmeticFuncType arithmetic_func_type, const void *arithmetic_func,
50                        const ArithmeticParameter *param);
51 
52 void TileConstTensor(const float *in_data, float *out_data, size_t ndim, const int *in_shape, const int *in_strides,
53                      const int *out_strides, const int *multiple);
54 
55 void BatchScalarCalc(const void *input0, const void *input1, void *output, int batch_size, int size, bool is_opt,
56                      const void *arithmetic_func, const ArithmeticWrapperInfo *wrapper_info,
57                      const ArithmeticParameter *param);
58 
59 void BroadcastRun(const void *input0, const void *input1, void *output, int dim, int out_count, int out_thread_stride,
60                   int break_pos, int data_type_len, ArithmeticFuncType arithmetic_func_type,
61                   const void *arithmetic_func, const ArithmeticParameter *param);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 #endif  // MINDSPORE_LITE_MICRO_CODER_WRAPPER_FP32_ARITHMETIC_FP32_WRAPPER_H_
67