load_ops.h 7.5 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
/* 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_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 已提交
30
      TouchOpRegistrar_##op_type##_##fpga()
H
hjchen2 已提交
31 32 33 34 35 36 37 38 39
#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();

xiebaiyuan's avatar
xiebaiyuan 已提交
40 41
#define LOAD_OP(op_type) \
  LOAD_CPU_OP(op_type);  \
H
hjchen2 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  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 已提交
57 58 59
#ifdef FILL_CONSTANT_OP
LOAD_OP(fill_constant)
#endif
H
hjchen2 已提交
60
#ifdef BATCHNORM_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
61
LOAD_OP1(batch_norm, CPU);
H
hjchen2 已提交
62 63
#endif
#ifdef BILINEAR_INTERP_OP
64
LOAD_OP1(bilinear_interp, CPU);
H
hjchen2 已提交
65 66
#endif
#ifdef BOXCODER_OP
67
LOAD_OP1(box_coder, CPU);
H
hjchen2 已提交
68 69
#endif
#ifdef CONCAT_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
70
LOAD_OP2(concat, CPU, FPGA);
H
hjchen2 已提交
71 72
#endif
#ifdef CONV_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
73
LOAD_OP2(conv2d, CPU, FPGA);
H
hjchen2 已提交
74 75
#endif
#ifdef LRN_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
76
LOAD_OP1(lrn, CPU);
H
hjchen2 已提交
77 78
#endif
#ifdef SIGMOID_OP
79
LOAD_OP1(sigmoid, CPU);
H
hjchen2 已提交
80 81
#endif
#ifdef FUSION_FC_RELU_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
82
LOAD_OP3(fusion_fc_relu, CPU, FPGA);
83
LOAD_FUSION_MATCHER(fusion_fc_relu);
H
hjchen2 已提交
84 85
#endif
#ifdef FUSION_ELEMENTWISEADDRELU_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
86
LOAD_OP3(fusion_elementwise_add_relu, CPU, FPGA);
87
LOAD_FUSION_MATCHER(fusion_elementwise_add_relu);
H
hjchen2 已提交
88 89
#endif
#ifdef SPLIT_OP
90
LOAD_OP1(split, CPU);
H
hjchen2 已提交
91 92
#endif
#ifdef RESIZE_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
93
LOAD_OP1(resize, CPU);
H
hjchen2 已提交
94 95
#endif
#ifdef FUSION_CONVADDBNRELU_OP
96 97
LOAD_OP2(fusion_conv_add_bn_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_bn_relu);
H
hjchen2 已提交
98 99
#endif
#ifdef RESHAPE_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
100
LOAD_OP1(reshape, CPU);
H
hjchen2 已提交
101
#endif
L
lijiancheng0614 已提交
102
#ifdef RESHAPE2_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
103
LOAD_OP1(reshape2, CPU);
L
lijiancheng0614 已提交
104
#endif
H
hjchen2 已提交
105
#ifdef TRANSPOSE_OP
106
LOAD_OP1(transpose, CPU);
H
hjchen2 已提交
107
#endif
L
lijiancheng0614 已提交
108 109 110
#ifdef TRANSPOSE2_OP
LOAD_OP1(transpose2, CPU);
#endif
H
hjchen2 已提交
111
#ifdef PRIORBOX_OP
112
LOAD_OP1(prior_box, CPU);
H
hjchen2 已提交
113 114
#endif
#ifdef FUSION_CONVADDRELU_OP
115 116
LOAD_OP2(fusion_conv_add_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_relu);
H
hjchen2 已提交
117 118
#endif
#ifdef FUSION_CONVADD_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
119
LOAD_OP1(fusion_conv_add, CPU);
120
LOAD_FUSION_MATCHER(fusion_conv_add);
H
hjchen2 已提交
121 122
#endif
#ifdef SOFTMAX_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
123
LOAD_OP1(softmax, CPU);
H
hjchen2 已提交
124 125
#endif
#ifdef SHAPE_OP
126
LOAD_OP1(shape, CPU);
H
hjchen2 已提交
127 128
#endif
#ifdef DEPTHWISECONV_OP
129
LOAD_OP1(depthwise_conv2d, CPU);
H
hjchen2 已提交
130 131
#endif
#ifdef CONV_TRANSPOSE_OP
132
LOAD_OP1(conv2d_transpose, CPU);
H
hjchen2 已提交
133 134
#endif
#ifdef SCALE_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
135
LOAD_OP1(scale, CPU);
H
hjchen2 已提交
136 137
#endif
#ifdef ELEMENTWISEADD_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
138
LOAD_OP1(elementwise_add, CPU);
H
hjchen2 已提交
139 140
#endif
#ifdef PRELU_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
141
LOAD_OP1(prelu, CPU);
H
hjchen2 已提交
142 143
#endif
#ifdef FLATTEN_OP
144
LOAD_OP1(flatten, CPU);
H
hjchen2 已提交
145 146
#endif
#ifdef FUSION_CONVBNADDRELU_OP
147 148
LOAD_OP2(fusion_conv_bn_add_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_bn_add_relu);
H
hjchen2 已提交
149 150
#endif
#ifdef FUSION_CONVBNRELU_OP
151 152
LOAD_OP2(fusion_conv_bn_relu, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_bn_relu);
H
hjchen2 已提交
153 154
#endif
#ifdef GRU_OP
155
LOAD_OP1(gru, CPU);
H
hjchen2 已提交
156
#endif
Z
zhaojiaying01 已提交
157 158 159
#ifdef GRU_UNIT_OP
LOAD_OP1(gru_unit, CPU);
#endif
H
hjchen2 已提交
160
#ifdef FUSION_CONVADDBN_OP
161 162
LOAD_OP2(fusion_conv_add_bn, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_add_bn);
H
hjchen2 已提交
163 164
#endif
#ifdef DROPOUT_OP
165
LOAD_OP2(dropout, CPU, FPGA);
H
hjchen2 已提交
166 167
#endif
#ifdef FUSION_DWCONVBNRELU_OP
168 169
LOAD_OP1(fusion_dwconv_bn_relu, CPU);
LOAD_FUSION_MATCHER(fusion_dwconv_bn_relu);
H
hjchen2 已提交
170 171
#endif
#ifdef CRF_OP
172
LOAD_OP1(crf_decoding, CPU);
H
hjchen2 已提交
173 174
#endif
#ifdef MUL_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
175
LOAD_OP1(mul, CPU);
H
hjchen2 已提交
176
#endif
Z
zhaojiaying01 已提交
177 178 179
#ifdef NORM_OP
LOAD_OP1(norm, CPU);
#endif
H
hjchen2 已提交
180
#ifdef RELU_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
181
LOAD_OP1(relu, CPU);
182
LOAD_OP1(relu6, CPU);
H
hjchen2 已提交
183 184
#endif
#ifdef IM2SEQUENCE_OP
185
LOAD_OP1(im2sequence, CPU);
H
hjchen2 已提交
186 187
#endif
#ifdef LOOKUP_OP
188
LOAD_OP1(lookup_table, CPU);
H
hjchen2 已提交
189 190
#endif
#ifdef FUSION_FC_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
191
LOAD_OP2(fusion_fc, CPU, FPGA);
192
LOAD_FUSION_MATCHER(fusion_fc);
H
hjchen2 已提交
193 194
#endif
#ifdef POOL_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
195
LOAD_OP2(pool2d, CPU, FPGA);
H
hjchen2 已提交
196 197
#endif
#ifdef MULTICLASSNMS_OP
198
LOAD_OP1(multiclass_nms, CPU);
H
hjchen2 已提交
199
#endif
L
lijiancheng0614 已提交
200 201 202
#ifdef POLYGONBOXTRANSFORM_OP
LOAD_OP1(polygon_box_transform, CPU);
#endif
E
eclipsess 已提交
203 204 205 206
#ifdef SUM_OP
LOAD_OP1(sum, CPU);
#endif
#ifdef ELEMENTWISEMUL_OP
E
eclipsess 已提交
207
LOAD_OP1(elementwise_mul, CPU);
E
eclipsess 已提交
208
#endif
H
hjchen2 已提交
209
#ifdef SLICE_OP
xiebaiyuan's avatar
xiebaiyuan 已提交
210
LOAD_OP1(slice, CPU);
H
hjchen2 已提交
211 212
#endif
#ifdef FUSION_CONVBN_OP
213 214
LOAD_OP2(fusion_conv_bn, CPU, FPGA);
LOAD_FUSION_MATCHER(fusion_conv_bn);
H
hjchen2 已提交
215
#endif
216 217 218
#ifdef ELEMENTWISESUB_OP
LOAD_OP1(elementwise_sub, CPU)
#endif
H
hjchen2 已提交
219 220 221 222 223 224
#ifdef TOP_K_OP
LOAD_OP1(top_k, CPU)
#endif
#ifdef CAST_OP
LOAD_OP1(cast, CPU)
#endif
H
hjchen2 已提交
225
#ifdef QUANT_OP
226
LOAD_OP1(quantize, CPU);
H
hjchen2 已提交
227 228
#endif
#ifdef DEQUANT_OP
229
LOAD_OP1(dequantize, CPU);
H
hjchen2 已提交
230
#endif
231 232 233 234
#ifdef FUSION_DEQUANT_BN_OP
LOAD_OP1(fusion_dequant_bn, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_bn);
#endif
235 236 237 238 239 240 241 242
#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 已提交
243 244 245 246
#ifdef FUSION_DEQUANT_ADD_BN_RELU_OP
LOAD_OP1(fusion_dequant_add_bn_relu, CPU);
LOAD_FUSION_MATCHER(fusion_dequant_add_bn_relu);
#endif
247 248 249 250 251 252 253 254
#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
255 256 257 258 259 260
#ifdef SEQUENCE_EXPAND_OP
LOAD_OP1(sequence_expand, CPU);
#endif
#ifdef SEQUENCE_POOL_OP
LOAD_OP1(sequence_pool, CPU);
#endif
261 262 263
#ifdef LOG_OP
LOAD_OP1(log, CPU);
#endif
264 265 266 267 268 269
#ifdef LOD_RESET_OP
LOAD_OP1(lod_reset, CPU);
#endif
#ifdef LESS_THAN_OP
LOAD_OP1(less_than, CPU);
#endif
Z
zhaojiaying01 已提交
270 271 272 273 274 275 276 277 278 279 280 281
#ifdef LOGICAL_AND_OP
LOAD_OP1(logical_and, CPU);
#endif
#ifdef LOGICAL_OR_OP
LOAD_OP1(logical_or, CPU);
#endif
#ifdef LOGICAL_NOT_OP
LOAD_OP1(logical_not, CPU);
#endif
#ifdef LOGICAL_XOR_OP
LOAD_OP1(logical_xor, CPU);
#endif
282 283 284 285 286 287 288 289 290
#ifdef WHILE_OP
LOAD_OP1(while, CPU);
#endif
#ifdef WRITE_TO_ARRAY_OP
LOAD_OP1(write_to_array, CPU);
#endif
#ifdef READ_FROM_ARRAY_OP
LOAD_OP1(read_from_array, CPU);
#endif
Z
zhaojiaying01 已提交
291 292 293 294 295 296
#ifdef IS_EMPTY_OP
LOAD_OP1(is_empty, CPU);
#endif
#ifdef INCREMENT_OP
LOAD_OP1(increment, CPU);
#endif
297 298 299 300 301 302 303 304 305
#ifdef ANCHOR_GENERATOR_OP
LOAD_OP1(anchor_generator, CPU);
#endif
#ifdef PROPOSAL_OP
LOAD_OP1(generate_proposals, CPU);
#endif
#ifdef PSROI_POOL_OP
LOAD_OP1(psroi_pool, CPU);
#endif
H
hjchen2 已提交
306 307 308
#ifdef ROI_PERSPECTIVE_OP
LOAD_OP1(roi_perspective_transform, CPU);
#endif
309 310 311
#ifdef BEAM_SEARCH_OP
LOAD_OP1(beam_search, CPU);
#endif
H
update  
hjchen2 已提交
312 313 314
#ifdef BEAM_SEARCH_DECODE_OP
LOAD_OP1(beam_search_decode, CPU);
#endif
H
hjchen2 已提交
315 316 317
#ifdef PAD2D_OP
LOAD_OP1(pad2d, CPU);
#endif
318 319 320
#ifdef ONE_HOT_OP
LOAD_OP1(one_hot, CPU);
#endif