Caffe2 - C++ API
A deep learning, cross platform ML framework
operator_fallback_ideep.cc
1 #include <caffe2/ideep/operators/operator_fallback_ideep.h>
2 #include <caffe2/ideep/utils/ideep_operator.h>
3 
4 #include <caffe2/operators/abs_op.h>
5 #include <caffe2/operators/accuracy_op.h>
6 #include <caffe2/operators/affine_channel_op.h>
7 #include <caffe2/operators/atan_op.h>
8 #include <caffe2/operators/batch_matmul_op.h>
9 #include <caffe2/operators/cast_op.h>
10 #include <caffe2/operators/clip_op.h>
11 #include <caffe2/operators/collect_and_distribute_fpn_rpn_proposals_op.h>
12 #include <caffe2/operators/cross_entropy_op.h>
13 #include <caffe2/operators/ctc_beam_search_decoder_op.h>
14 #include <caffe2/operators/ctc_greedy_decoder_op.h>
15 #include <caffe2/operators/distance_op.h>
16 #include <caffe2/operators/dropout_op.h>
17 #include <caffe2/operators/elementwise_add_op.h>
18 #include <caffe2/operators/elementwise_div_op.h>
19 #include <caffe2/operators/elementwise_mul_op.h>
20 #include <caffe2/operators/elementwise_ops.h>
21 #include <caffe2/operators/elementwise_sub_op.h>
22 #include <caffe2/operators/expand_op.h>
23 #include <caffe2/operators/filler_op.h>
24 #include <caffe2/operators/flatten_op.h>
25 #include <caffe2/operators/gather_op.h>
26 #include <caffe2/operators/generate_proposals_op.h>
27 #include <caffe2/operators/given_tensor_fill_op.h>
28 #include <caffe2/operators/load_save_op.h>
29 #include <caffe2/operators/loss_op.h>
30 #include <caffe2/operators/normalize_op.h>
31 #include <caffe2/operators/order_switch_ops.h>
32 #include <caffe2/operators/pad_op.h>
33 #include <caffe2/operators/prelu_op.h>
34 #include <caffe2/operators/reduce_ops.h>
35 #include <caffe2/operators/rmac_regions_op.h>
36 #include <caffe2/operators/roi_align_op.h>
37 #include <caffe2/operators/roi_align_rotated_op.h>
38 #include <caffe2/operators/roi_pool_op.h>
39 #include <caffe2/operators/scale_op.h>
40 #include <caffe2/operators/slice_op.h>
41 #include <caffe2/operators/softmax_op.h>
42 #include <caffe2/operators/softmax_with_loss_op.h>
43 #include <caffe2/operators/sqrt_op.h>
44 #include <caffe2/operators/stop_gradient.h>
45 #include <caffe2/operators/tanh_op.h>
46 #include <caffe2/operators/tensor_protos_db_input.h>
47 #include <caffe2/operators/transpose_op.h>
48 #include <caffe2/operators/utility_ops.h>
49 #include <caffe2/queue/queue_ops.h>
50 #include <caffe2/sgd/iter_op.h>
51 #include <caffe2/sgd/learning_rate_op.h>
52 #include "caffe2/operators/bbox_transform_op.h"
53 #include "caffe2/operators/box_with_nms_limit_op.h"
54 
55 #ifdef CAFFE2_USE_GLOO
56 #include <caffe2/contrib/gloo/common_world_ops.h>
57 #include <caffe2/contrib/gloo/broadcast_ops.h>
58 #include <caffe2/contrib/gloo/allreduce_ops.h>
59 #include <caffe2/contrib/gloo/allgather_ops.h>
60 #include <caffe2/contrib/gloo/barrier_ops.h>
61 #include <caffe2/contrib/gloo/reduce_scatter_ops.h>
62 #endif
63 
64 // can add more non-IDEEP operators if needed
65 namespace caffe2 {
66 
67 // Boolean operators
68 REGISTER_IDEEP_COMPARE_OPERATOR(EQ);
69 REGISTER_IDEEP_COMPARE_OPERATOR(GT);
70 REGISTER_IDEEP_COMPARE_OPERATOR(GE);
71 REGISTER_IDEEP_COMPARE_OPERATOR(LT);
72 REGISTER_IDEEP_COMPARE_OPERATOR(LE);
73 REGISTER_IDEEP_COMPARE_OPERATOR(NE);
74 
75 REGISTER_IDEEP_OPERATOR(Softmax, IDEEPFallbackOp<SoftmaxOp<float, CPUContext>>);
76 REGISTER_IDEEP_OPERATOR(
77  LabelCrossEntropy,
78  IDEEPFallbackOp<LabelCrossEntropyOp<float, CPUContext>>);
79 REGISTER_IDEEP_OPERATOR(
80  AveragedLoss,
81  IDEEPFallbackOp<AveragedLoss<float, CPUContext>, SkipIndices<0>>);
82 REGISTER_IDEEP_OPERATOR(Flatten, IDEEPFallbackOp<FlattenOp<CPUContext>>);
83 REGISTER_IDEEP_OPERATOR(ResizeLike, IDEEPFallbackOp<ResizeLikeOp<CPUContext>>);
84 REGISTER_IDEEP_OPERATOR(Transpose, IDEEPFallbackOp<TransposeOp<CPUContext>>);
85 REGISTER_IDEEP_OPERATOR(Slice, IDEEPFallbackOp<SliceOp<CPUContext>>);
86 REGISTER_IDEEP_OPERATOR(Clip, IDEEPFallbackOp<ClipOp<float, CPUContext>>);
87 REGISTER_IDEEP_OPERATOR(
88  ScatterAssign,
89  IDEEPFallbackOp<ScatterAssignOp<CPUContext>>);
90 REGISTER_IDEEP_OPERATOR(
91  Cast,
92  IDEEPFallbackOp<CastOp<CPUContext>>);
93 
94 // filter operators
95 REGISTER_IDEEP_OPERATOR(
96  XavierFill,
97  IDEEPFallbackOp<XavierFillOp<float, CPUContext>>);
98 REGISTER_IDEEP_OPERATOR(
99  ConstantFill,
100  IDEEPFallbackOp<ConstantFillOp<CPUContext>>);
101 REGISTER_IDEEP_OPERATOR(
102  GaussianFill,
103  IDEEPFallbackOp<GaussianFillOp<float, CPUContext>>);
104 REGISTER_IDEEP_OPERATOR(
105  MSRAFill,
106  IDEEPFallbackOp<MSRAFillOp<float, CPUContext>>);
107 REGISTER_IDEEP_OPERATOR(
109  IDEEPFallbackOp<GivenTensorFillOp<float, CPUContext>>);
110 // Not supported tensor types in below FillOp
111 REGISTER_IDEEP_OPERATOR(
112  GivenTensorDoubleFill,
113  IDEEPFallbackOp<GivenTensorFillOp<double, CPUContext>, SkipIndices<0>>);
114 REGISTER_IDEEP_OPERATOR(
115  GivenTensorBoolFill,
116  IDEEPFallbackOp<GivenTensorFillOp<bool, CPUContext>, SkipIndices<0>>);
117 REGISTER_IDEEP_OPERATOR(
118  GivenTensorIntFill,
119  IDEEPFallbackOp<GivenTensorFillOp<int, CPUContext>, SkipIndices<0>>);
120 REGISTER_IDEEP_OPERATOR(
121  GivenTensorInt64Fill,
122  IDEEPFallbackOp<GivenTensorFillOp<int64_t, CPUContext>, SkipIndices<0>>);
123 REGISTER_IDEEP_OPERATOR(
124  GivenTensorStringFill,
125  IDEEPFallbackOp<GivenTensorFillOp<std::string, CPUContext>, SkipIndices<0>>);
126 REGISTER_IDEEP_OPERATOR(Load, IDEEPFallbackOp<LoadOp<CPUContext>>);
127 REGISTER_IDEEP_OPERATOR(Save, IDEEPFallbackOp<SaveOp<CPUContext>>);
128 
129 REGISTER_IDEEP_OPERATOR(
130  RMACRegions,
131  IDEEPFallbackOp<RMACRegionsOp<CPUContext>>);
132 REGISTER_IDEEP_OPERATOR(RoIPool, IDEEPFallbackOp<RoIPoolOp<float, CPUContext>>);
133 REGISTER_IDEEP_OPERATOR(
134  RoIAlign,
135  IDEEPFallbackOp<RoIAlignOp<float, CPUContext>>);
136 REGISTER_IDEEP_OPERATOR(
137  RoIAlignRotated,
138  IDEEPFallbackOp<RoIAlignRotatedOp<float, CPUContext>>);
139 REGISTER_IDEEP_OPERATOR(
140  GenerateProposals,
141  IDEEPFallbackOp<GenerateProposalsOp<CPUContext>>);
142 REGISTER_IDEEP_OPERATOR(
143  GenerateProposalsCPP,
144  IDEEPFallbackOp<GenerateProposalsOp<CPUContext>>);
145 REGISTER_IDEEP_OPERATOR(
146  CollectAndDistributeFpnRpnProposals,
147  IDEEPFallbackOp<CollectAndDistributeFpnRpnProposalsOp<CPUContext>>);
148 REGISTER_IDEEP_OPERATOR(
149  BoxWithNMSLimit,
150  IDEEPFallbackOp<BoxWithNMSLimitOp<CPUContext>, SkipIndices<0,1,2>>);
151 REGISTER_IDEEP_OPERATOR(
152  BBoxTransform,
153  IDEEPFallbackOp<BBoxTransformOp<float, CPUContext>>);
154 REGISTER_IDEEP_OPERATOR(
155  AffineChannel,
156  IDEEPFallbackOp<AffineChannelOp<float, CPUContext>>);
157 REGISTER_IDEEP_OPERATOR(
158  StopGradient,
159  IDEEPFallbackOp<StopGradientOp<CPUContext>>);
160 
161 REGISTER_IDEEP_OPERATOR(
162  PadImage,
163  IDEEPFallbackOp<PadImageOp<float, CPUContext>>);
164 REGISTER_IDEEP_OPERATOR(
165  PRelu,
166  IDEEPFallbackOp<PReluOp<float, CPUContext>>);
167 
168 // ctc decoder operators
169 REGISTER_IDEEP_OPERATOR(
170  CTCGreedyDecoder,
171  IDEEPFallbackOp<CTCGreedyDecoderOp<CPUContext>>);
172 REGISTER_IDEEP_OPERATOR(
173  CTCBeamSearchDecoder,
174  IDEEPFallbackOp<CTCBeamSearchDecoderOp<CPUContext>>);
175 
176 REGISTER_IDEEP_OPERATOR(
177  AveragedLossGradient,
178  IDEEPFallbackOp<AveragedLossGradient<float, CPUContext>>);
179 REGISTER_IDEEP_OPERATOR(
180  LabelCrossEntropyGradient,
181  IDEEPFallbackOp<LabelCrossEntropyGradientOp<float, CPUContext>>);
182 REGISTER_IDEEP_OPERATOR(
183  SoftmaxGradient,
184  IDEEPFallbackOp<SoftmaxGradientOp<float, CPUContext>>);
185 REGISTER_IDEEP_OPERATOR(
186  Iter,
187  IDEEPFallbackOp<IterOp<CPUContext>>);
188 REGISTER_IDEEP_OPERATOR(
189  LearningRate,
190  IDEEPFallbackOp<LearningRateOp<float, CPUContext>>);
191 REGISTER_IDEEP_OPERATOR(
192  Abs,
193  IDEEPFallbackOp<UnaryElementwiseOp<
194  TensorTypes<float>, CPUContext, AbsFunctor<CPUContext>>>);
195 REGISTER_IDEEP_OPERATOR(
196  Atan,
197  IDEEPFallbackOp<UnaryElementwiseOp<
198  TensorTypes<float>, CPUContext, AtanFunctor<CPUContext>>>);
199 REGISTER_IDEEP_OPERATOR(
200  Sqrt,
201  IDEEPFallbackOp<UnaryElementwiseOp<
202  TensorTypes<float>, CPUContext, SqrtFunctor<CPUContext>>>);
203 REGISTER_IDEEP_OPERATOR(
204  Div,
205  IDEEPFallbackOp<BinaryElementwiseOp<
206  NumericTypes, CPUContext, DivFunctor<CPUContext>>>);
207 REGISTER_IDEEP_OPERATOR(
208  Mul,
209  IDEEPFallbackOp<
210  BinaryElementwiseOp<NumericTypes, CPUContext, MulFunctor<CPUContext>>>);
211 REGISTER_IDEEP_OPERATOR(
212  Sub,
213  IDEEPFallbackOp<BinaryElementwiseOp<
214  NumericTypes, CPUContext, SubFunctor<CPUContext>>>);
215 REGISTER_IDEEP_OPERATOR(
216  Tanh,
217  IDEEPFallbackOp<UnaryElementwiseOp<
218  TensorTypes<float>,
219  CPUContext,
220  TanhFunctor<CPUContext>>>);
221 REGISTER_IDEEP_OPERATOR(
222  L1Distance,
223  IDEEPFallbackOp<L1DistanceOp<float, CPUContext>>);
224 REGISTER_IDEEP_OPERATOR(Scale, IDEEPFallbackOp<ScaleOp<CPUContext>>);
225 REGISTER_IDEEP_OPERATOR(
226  Accuracy,
227  IDEEPFallbackOp<AccuracyOp<float, CPUContext>>);
228 
229 REGISTER_IDEEP_OPERATOR(
230  AddGradient,
231  IDEEPFallbackOp<BinaryElementwiseGradientOp<
232  NumericTypes,
233  CPUContext,
234  AddFunctor<CPUContext>>>);
235 REGISTER_IDEEP_OPERATOR(
236  TanhGradient,
237  IDEEPFallbackOp<BinaryElementwiseOp<
238  TensorTypes<float>,
239  CPUContext,
240  TanhGradientFunctor<CPUContext>>>);
241 REGISTER_IDEEP_OPERATOR(
242  MulGradient,
243  IDEEPFallbackOp<BinaryElementwiseGradientOp<
244  NumericTypes,
245  CPUContext,
246  MulFunctor<CPUContext>>>);
247 REGISTER_IDEEP_OPERATOR(TensorProtosDBInput, IDEEPFallbackOp<TensorProtosDBInput<CPUContext>>);
248 REGISTER_IDEEP_OPERATOR(CloseBlobsQueue, IDEEPFallbackOp<CloseBlobsQueueOp<CPUContext>>);
249 REGISTER_IDEEP_OPERATOR(
250  SoftmaxWithLoss,
251  IDEEPFallbackOp<SoftmaxWithLossOp<float, CPUContext>>);
252 REGISTER_IDEEP_OPERATOR(
253  SoftmaxWithLossGradient,
254  IDEEPFallbackOp<SoftmaxWithLossGradientOp<float, CPUContext>>);
255 REGISTER_IDEEP_OPERATOR(
256  NHWC2NCHW,
257  IDEEPFallbackOp<NHWC2NCHWOp<float, CPUContext>>);
258 REGISTER_IDEEP_OPERATOR(
259  NCHW2NHWC,
260  IDEEPFallbackOp<NCHW2NHWCOp<float, CPUContext>>);
261 
262 REGISTER_IDEEP_OPERATOR(
263  Expand,
264  IDEEPFallbackOp<ExpandOp<
265  TensorTypes<std::int32_t, std::int64_t, float, double>,
266  CPUContext>>);
267 REGISTER_IDEEP_OPERATOR(Gather, IDEEPFallbackOp<GatherOp<CPUContext>>);
268 
269 REGISTER_IDEEP_OPERATOR(
270  Normalize,
271  IDEEPFallbackOp<NormalizeOp<float, CPUContext>>);
272 REGISTER_IDEEP_OPERATOR(
273  ReduceL2,
274  IDEEPFallbackOp<
275  ReduceOp<TensorTypes<float>, CPUContext, L2Reducer<CPUContext>>>);
276 REGISTER_IDEEP_OPERATOR(
277  ReduceSum,
278  IDEEPFallbackOp<ReduceOp<
279  TensorTypes<std::int32_t, std::int64_t, float, double>,
280  CPUContext,
281  SumReducer<CPUContext>>>);
282 REGISTER_IDEEP_OPERATOR(
283  ReduceMean,
284  IDEEPFallbackOp<ReduceOp<
285  TensorTypes<float>, CPUContext, MeanReducer<CPUContext>>>);
286 REGISTER_IDEEP_OPERATOR(
287  BatchMatMul,
288  IDEEPFallbackOp<BatchMatMulOp<CPUContext>>);
289 
290 #ifdef CAFFE2_USE_GLOO
291 namespace gloo {
292 // gloo operators
293 REGISTER_IDEEP_OPERATOR(
294  CreateCommonWorld,
295  IDEEPFallbackOp<CreateCommonWorld<CPUContext>, SkipIndices<0>>);
296 REGISTER_IDEEP_OPERATOR(
297  CloneCommonWorld,
298  IDEEPFallbackOp<CloneCommonWorld<CPUContext>, SkipIndices<0>>);
299 REGISTER_IDEEP_OPERATOR(
300  DestroyCommonWorld,
301  IDEEPFallbackOp<DestroyCommonWorld>);
302 REGISTER_IDEEP_OPERATOR(
303  Broadcast,
304  IDEEPFallbackOp<BroadcastOp<CPUContext>>);
305 REGISTER_IDEEP_OPERATOR(
306  Allreduce,
307  IDEEPFallbackOp<AllreduceOp<CPUContext>>);
308 REGISTER_IDEEP_OPERATOR(
309  Allgather,
310  IDEEPFallbackOp<AllgatherOp<CPUContext>>);
311 REGISTER_IDEEP_OPERATOR(
312  Barrier,
313  IDEEPFallbackOp<BarrierOp<CPUContext>>);
314 REGISTER_IDEEP_OPERATOR(
315  ReduceScatter,
316  IDEEPFallbackOp<ReduceScatterOp<CPUContext>>);
317 
318 } // namespace gloo
319 #endif
320 
321 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13