load_ops.h 6.8 KB
Newer Older
H
hjchen2 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#pragma once

#ifdef PADDLE_MOBILE_CPU
#define LOAD_CPU_OP(op_type)                                           \
  extern int TouchOpRegistrar_##op_type##_##cpu();                     \
  static int use_op_itself_##op_type##_##cpu __attribute__((unused)) = \
      TouchOpRegistrar_##op_type##_##cpu()
#else
#define LOAD_CPU_OP(op_type)
#endif

#ifdef PADDLE_MOBILE_MALI_GPU
#define LOAD_MALI_GPU_OP(op_type)                                           \
  extern int TouchOpRegistrar_##op_type##_##mali_gpu();                     \
  static int use_op_itself_##op_type##_##mali_gpu __attribute__((unused)) = \
      TouchOpRegistrar_##op_type##_##mali_gpu()
#else
#define LOAD_MALI_GPU_OP(op_type)
#endif

#ifdef PADDLE_MOBILE_FPGA
#define LOAD_FPGA_OP(op_type)                                           \
  extern int TouchOpRegistrar_##op_type##_##fpga();                     \
  static int use_op_itself_##op_type##_##fpga __attribute__((unused)) = \
H
hjchen2 已提交
39
      TouchOpRegistrar_##op_type##_##fpga()
H
hjchen2 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#else
#define LOAD_FPGA_OP(op_type)
#endif

#define LOAD_FUSION_MATCHER(op_type)                                       \
  extern int TouchFusionMatcherRegistrar_##op_type();                      \
  static int use_fusion_matcher_itself_##op_type __attribute__((unused)) = \
      TouchFusionMatcherRegistrar_##op_type();

#define LOAD_OP(op_type)     \
  LOAD_CPU_OP(op_type);      \
  LOAD_MALI_GPU_OP(op_type); \
  LOAD_FPGA_OP(op_type);

#define LOAD_OP1(op_type, device_type) LOAD_##device_type##_OP(op_type);

#define LOAD_OP2(op_type, device_type1, device_type2) \
  LOAD_OP1(op_type, device_type1)                     \
  LOAD_OP1(op_type, device_type2)

#define LOAD_OP3(op_type, device_type1, device_type2, device_type3) \
  LOAD_OP2(op_type, device_type1, device_type2)                     \
  LOAD_OP1(op_type, device_type3)

// load requared ops
LOAD_OP(feed)
LOAD_OP(fetch)
L
lijiancheng0614 已提交
67 68 69
#ifdef FILL_CONSTANT_OP
LOAD_OP(fill_constant)
#endif
H
hjchen2 已提交
70
#ifdef BATCHNORM_OP
71
LOAD_OP2(batch_norm, CPU, MALI_GPU);
H
hjchen2 已提交
72 73
#endif
#ifdef BILINEAR_INTERP_OP
74
LOAD_OP1(bilinear_interp, CPU);
H
hjchen2 已提交
75 76
#endif
#ifdef BOXCODER_OP
77
LOAD_OP1(box_coder, CPU);
H
hjchen2 已提交
78 79
#endif
#ifdef CONCAT_OP
80
LOAD_OP3(concat, CPU, MALI_GPU, FPGA);
H
hjchen2 已提交
81 82
#endif
#ifdef CONV_OP
83
LOAD_OP3(conv2d, CPU, MALI_GPU, FPGA);
H
hjchen2 已提交
84 85
#endif
#ifdef LRN_OP
86
LOAD_OP2(lrn, CPU, MALI_GPU);
H
hjchen2 已提交
87 88
#endif
#ifdef SIGMOID_OP
89
LOAD_OP1(sigmoid, CPU);
H
hjchen2 已提交
90 91
#endif
#ifdef FUSION_FC_RELU_OP
92 93
LOAD_OP3(fusion_fc_relu, CPU, MALI_GPU, FPGA);
LOAD_FUSION_MATCHER(fusion_fc_relu);
H
hjchen2 已提交
94 95
#endif
#ifdef FUSION_ELEMENTWISEADDRELU_OP
96 97
LOAD_OP3(fusion_elementwise_add_relu, CPU, MALI_GPU, FPGA);
LOAD_FUSION_MATCHER(fusion_elementwise_add_relu);
H
hjchen2 已提交
98 99
#endif
#ifdef SPLIT_OP
100
LOAD_OP1(split, CPU);
H
hjchen2 已提交
101 102
#endif
#ifdef RESIZE_OP
103
LOAD_OP2(resize, CPU, MALI_GPU);
H
hjchen2 已提交
104 105
#endif
#ifdef FUSION_CONVADDBNRELU_OP
106 107
LOAD_OP2(fusion_conv_add_bn_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_bn_relu);
H
hjchen2 已提交
108 109
#endif
#ifdef RESHAPE_OP
110
LOAD_OP2(reshape, CPU, MALI_GPU);
H
hjchen2 已提交
111
#endif
L
lijiancheng0614 已提交
112 113 114
#ifdef RESHAPE2_OP
LOAD_OP2(reshape2, CPU, MALI_GPU);
#endif
H
hjchen2 已提交
115
#ifdef TRANSPOSE_OP
116
LOAD_OP1(transpose, CPU);
H
hjchen2 已提交
117
#endif
L
lijiancheng0614 已提交
118 119 120
#ifdef TRANSPOSE2_OP
LOAD_OP1(transpose2, CPU);
#endif
H
hjchen2 已提交
121
#ifdef PRIORBOX_OP
122
LOAD_OP1(prior_box, CPU);
H
hjchen2 已提交
123 124
#endif
#ifdef FUSION_CONVADDRELU_OP
125 126
LOAD_OP2(fusion_conv_add_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_relu);
H
hjchen2 已提交
127 128
#endif
#ifdef FUSION_CONVADDADDPRELU_OP
129 130
LOAD_OP2(fusion_conv_add_add_prelu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_add_prelu);
H
hjchen2 已提交
131 132
#endif
#ifdef FUSION_CONVADD_OP
133 134
LOAD_OP2(fusion_conv_add, CPU, MALI_GPU);
LOAD_FUSION_MATCHER(fusion_conv_add);
H
hjchen2 已提交
135 136
#endif
#ifdef SOFTMAX_OP
137
LOAD_OP2(softmax, CPU, MALI_GPU);
H
hjchen2 已提交
138 139
#endif
#ifdef SHAPE_OP
140
LOAD_OP1(shape, CPU);
H
hjchen2 已提交
141 142
#endif
#ifdef DEPTHWISECONV_OP
143
LOAD_OP1(depthwise_conv2d, CPU);
H
hjchen2 已提交
144 145
#endif
#ifdef CONV_TRANSPOSE_OP
146
LOAD_OP1(conv2d_transpose, CPU);
H
hjchen2 已提交
147 148
#endif
#ifdef SCALE_OP
149
LOAD_OP2(scale, CPU, MALI_GPU);
H
hjchen2 已提交
150 151
#endif
#ifdef ELEMENTWISEADD_OP
152
LOAD_OP2(elementwise_add, CPU, MALI_GPU);
H
hjchen2 已提交
153 154
#endif
#ifdef PRELU_OP
155
LOAD_OP2(prelu, CPU, MALI_GPU);
H
hjchen2 已提交
156 157
#endif
#ifdef FLATTEN_OP
158
LOAD_OP1(flatten, CPU);
H
hjchen2 已提交
159 160
#endif
#ifdef FUSION_CONVBNADDRELU_OP
161 162
LOAD_OP2(fusion_conv_bn_add_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_bn_add_relu);
H
hjchen2 已提交
163 164
#endif
#ifdef FUSION_CONVBNRELU_OP
165 166
LOAD_OP2(fusion_conv_bn_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_bn_relu);
H
hjchen2 已提交
167 168
#endif
#ifdef GRU_OP
169
LOAD_OP1(gru, CPU);
H
hjchen2 已提交
170 171
#endif
#ifdef FUSION_CONVADDBN_OP
172 173
LOAD_OP2(fusion_conv_add_bn, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_bn);
H
hjchen2 已提交
174 175
#endif
#ifdef DROPOUT_OP
176
LOAD_OP2(dropout, CPU, FPGA);
H
hjchen2 已提交
177 178
#endif
#ifdef FUSION_CONVADDPRELU_OP
179 180
LOAD_OP2(fusion_conv_add_prelu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_prelu);
H
hjchen2 已提交
181 182
#endif
#ifdef FUSION_DWCONVBNRELU_OP
183 184
LOAD_OP1(fusion_dwconv_bn_relu, CPU);
LOAD_FUSION_MATCHER(fusion_dwconv_bn_relu);
H
hjchen2 已提交
185 186
#endif
#ifdef CRF_OP
187
LOAD_OP1(crf_decoding, CPU);
H
hjchen2 已提交
188 189
#endif
#ifdef MUL_OP
190
LOAD_OP2(mul, CPU, MALI_GPU);
H
hjchen2 已提交
191 192
#endif
#ifdef RELU_OP
193
LOAD_OP2(relu, CPU, MALI_GPU);
194
LOAD_OP1(relu6, CPU);
H
hjchen2 已提交
195 196
#endif
#ifdef IM2SEQUENCE_OP
197
LOAD_OP1(im2sequence, CPU);
H
hjchen2 已提交
198 199
#endif
#ifdef LOOKUP_OP
200
LOAD_OP1(lookup_table, CPU);
H
hjchen2 已提交
201 202
#endif
#ifdef FUSION_FC_OP
203 204
LOAD_OP3(fusion_fc, CPU, MALI_GPU, FPGA);
LOAD_FUSION_MATCHER(fusion_fc);
H
hjchen2 已提交
205 206
#endif
#ifdef POOL_OP
207
LOAD_OP3(pool2d, CPU, MALI_GPU, FPGA);
H
hjchen2 已提交
208 209
#endif
#ifdef MULTICLASSNMS_OP
210
LOAD_OP1(multiclass_nms, CPU);
H
hjchen2 已提交
211
#endif
L
lijiancheng0614 已提交
212 213 214
#ifdef POLYGONBOXTRANSFORM_OP
LOAD_OP1(polygon_box_transform, CPU);
#endif
E
eclipsess 已提交
215 216 217 218
#ifdef SUM_OP
LOAD_OP1(sum, CPU);
#endif
#ifdef ELEMENTWISEMUL_OP
E
eclipsess 已提交
219
LOAD_OP1(elementwise_mul, CPU);
E
eclipsess 已提交
220
#endif
H
hjchen2 已提交
221
#ifdef SLICE_OP
222
LOAD_OP2(slice, CPU, MALI_GPU);
H
hjchen2 已提交
223 224
#endif
#ifdef FUSION_CONVBN_OP
225 226
LOAD_OP2(fusion_conv_bn, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_bn);
H
hjchen2 已提交
227
#endif
228 229 230
#ifdef ELEMENTWISESUB_OP
LOAD_OP1(elementwise_sub, CPU)
#endif
H
hjchen2 已提交
231
#ifdef QUANT_OP
232
LOAD_OP1(quantize, CPU);
H
hjchen2 已提交
233 234
#endif
#ifdef DEQUANT_OP
235
LOAD_OP1(dequantize, CPU);
H
hjchen2 已提交
236
#endif
237 238 239 240 241 242 243 244
#ifdef FUSION_DEQUANT_ADD_BN_OP
LOAD_OP1(fusion_dequant_add_bn, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_add_bn);
#endif
#ifdef FUSION_DEQUANT_BN_RELU_OP
LOAD_OP1(fusion_dequant_bn_relu, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_bn_relu);
#endif
H
hjchen2 已提交
245 246 247 248
#ifdef FUSION_DEQUANT_ADD_BN_RELU_OP
LOAD_OP1(fusion_dequant_add_bn_relu, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_add_bn_relu);
#endif
249 250 251 252 253 254 255 256
#ifdef FUSION_DEQUANT_ADD_BN_QUANT_OP
LOAD_OP1(fusion_dequant_add_bn_quant, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_add_bn_quant);
#endif
#ifdef FUSION_DEQUANT_ADD_BN_RELU_QUANT_OP
LOAD_OP1(fusion_dequant_add_bn_relu_quant, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_add_bn_relu_quant);
#endif