load_ops.h 6.3 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 39 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
/* 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)) = \
      TouchOpRegistrar_##op_type##_##mali_gpu()
#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)
#ifdef BATCHNORM_OP
LOAD_OP2(batch_norm, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef BILINEAR_INTERP_OP
LOAD_OP1(bilinear_interp, CPU)  // NOLINT
#endif
#ifdef BOXCODER_OP
LOAD_OP1(box_coder, CPU)  // NOLINT
#endif
#ifdef CONCAT_OP
LOAD_OP3(concat, CPU, MALI_GPU, FPGA)  // NOLINT
#endif
#ifdef CONV_OP
LOAD_OP3(conv2d, CPU, MALI_GPU, FPGA)  // NOLINT
#endif
#ifdef LRN_OP
LOAD_OP2(lrn, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef SIGMOID_OP
LOAD_OP1(sigmoid, CPU)  // NOLINT
#endif
#ifdef FUSION_FC_RELU_OP
LOAD_OP3(fusion_fc_relu, CPU, MALI_GPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_fc_relu)            // NOLINT
#endif
#ifdef FUSION_ELEMENTWISEADDRELU_OP
LOAD_OP3(fusion_elementwise_add_relu, CPU, MALI_GPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_elementwise_add_relu)            // NOLINT
#endif
#ifdef SPLIT_OP
LOAD_OP1(split, CPU)  // NOLINT
#endif
#ifdef RESIZE_OP
LOAD_OP2(resize, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef FUSION_CONVADDBNRELU_OP
LOAD_OP2(fusion_conv_add_bn_relu, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_add_bn_relu)  // NOLINT
#endif
#ifdef RESHAPE_OP
LOAD_OP2(reshape, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef TRANSPOSE_OP
LOAD_OP1(transpose, CPU)  // NOLINT
#endif
#ifdef PRIORBOX_OP
LOAD_OP1(prior_box, CPU)  // NOLINT
#endif
#ifdef FUSION_CONVADDRELU_OP
LOAD_OP2(fusion_conv_add_relu, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_add_relu)  // NOLINT
#endif
#ifdef FUSION_CONVADDADDPRELU_OP
LOAD_OP2(fusion_conv_add_add_prelu, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_add_add_prelu)  // NOLINT
#endif
#ifdef FUSION_CONVADD_OP
LOAD_OP2(fusion_conv_add, CPU, MALI_GPU)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_add)      // NOLINT
#endif
#ifdef SOFTMAX_OP
LOAD_OP2(softmax, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef SHAPE_OP
LOAD_OP1(shape, CPU)  // NOLINT
#endif
#ifdef DEPTHWISECONV_OP
LOAD_OP1(depthwise_conv2d, CPU)  // NOLINT
#endif
#ifdef CONV_TRANSPOSE_OP
LOAD_OP1(conv2d_transpose, CPU)  // NOLINT
#endif
#ifdef SCALE_OP
LOAD_OP2(scale, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef ELEMENTWISEADD_OP
LOAD_OP2(elementwise_add, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef PRELU_OP
LOAD_OP2(prelu, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef FLATTEN_OP
LOAD_OP1(flatten, CPU)  // NOLINT
#endif
#ifdef FUSION_CONVBNADDRELU_OP
LOAD_OP2(fusion_conv_bn_add_relu, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_bn_add_relu)  // NOLINT
#endif
#ifdef FUSION_CONVBNRELU_OP
LOAD_OP2(fusion_conv_bn_relu, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_bn_relu)  // NOLINT
#endif
#ifdef GRU_OP
LOAD_OP1(gru, CPU)  // NOLINT
#endif
#ifdef FUSION_CONVADDBN_OP
LOAD_OP2(fusion_conv_add_bn, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_add_bn)  // NOLINT
#endif
#ifdef DROPOUT_OP
LOAD_OP2(dropout, CPU, FPGA)  // NOLINT
#endif
#ifdef FUSION_CONVADDPRELU_OP
LOAD_OP2(fusion_conv_add_prelu, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_add_prelu)  // NOLINT
#endif
#ifdef FUSION_DWCONVBNRELU_OP
LOAD_OP1(fusion_dwconv_bn_relu, CPU)        // NOLINT
LOAD_FUSION_MATCHER(fusion_dwconv_bn_relu)  // NOLINT
#endif
#ifdef CRF_OP
LOAD_OP1(crf_decoding, CPU)  // NOLINT
#endif
#ifdef MUL_OP
LOAD_OP2(mul, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef RELU_OP
LOAD_OP2(relu, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef IM2SEQUENCE_OP
LOAD_OP1(im2sequence, CPU)  // NOLINT
#endif
#ifdef LOOKUP_OP
LOAD_OP1(lookup_table, CPU)  // NOLINT
#endif
#ifdef FUSION_FC_OP
LOAD_OP3(fusion_fc, CPU, MALI_GPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_fc)            // NOLINT
#endif
#ifdef POOL_OP
LOAD_OP3(pool2d, CPU, MALI_GPU, FPGA)  // NOLINT
#endif
#ifdef MULTICLASSNMS_OP
LOAD_OP1(multiclass_nms, CPU)  // NOLINT
#endif
#ifdef SLICE_OP
LOAD_OP2(slice, CPU, MALI_GPU)  // NOLINT
#endif
#ifdef FUSION_CONVBN_OP
LOAD_OP2(fusion_conv_bn, CPU, FPGA)  // NOLINT
LOAD_FUSION_MATCHER(fusion_conv_bn)  // NOLINT
#endif
LOAD_OP1(quantize, CPU)    // NOLINT
LOAD_OP1(dequantize, CPU)  // NOLINT