Caffe2 - C++ API
A deep learning, cross platform ML framework
conv_transpose_op_mobile.h
1 #ifndef CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
2 #define CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
3 
4 #include "caffe2/core/common.h"
5 
6 #ifndef CAFFE2_MOBILE
7 #error "mobile build state not defined"
8 #endif
9 
10 #if CAFFE2_MOBILE
11 
12 #include "caffe2/core/context.h"
13 #include "caffe2/core/operator.h"
14 #include "caffe2/operators/conv_transpose_unpool_op_base.h"
15 
16 namespace caffe2 {
17 
18 template <typename T, class Context>
19 class ConvTransposeMobileOp final : public ConvTransposeUnpoolBase<Context> {
20  public:
21  USE_CONV_TRANSPOSE_UNPOOL_BASE_FUNCTIONS(Context);
22  ConvTransposeMobileOp(const OperatorDef& operator_def, Workspace* ws)
23  : ConvTransposeUnpoolBase<Context>(operator_def, ws) {
24  OPERATOR_NEEDS_FEATURE(order_ == StorageOrder::NCHW, "Only NCHW order is supported right now.");
25  OPERATOR_NEEDS_FEATURE(
26  this->pad_l() == 0, "operator does not handle row width padding");
27  OPERATOR_NEEDS_FEATURE(
28  this->pad_r() == 0, "operator does not handle row width padding");
29  OPERATOR_NEEDS_FEATURE(this->stride_w() <= 4, "stride width must be <= 4");
30  }
31 
32  bool RunOnDeviceWithOrderNCHW() override;
33  bool RunOnDeviceWithOrderNHWC() override;
34 
35  private:
36  // We store a numThreasds per-worker tiles of Y, and numThreads per-worker threadBuffer for the
37  // gemm output, laid out in that order.
38  TensorCPU threadBuffer_;
39 
40  // Input: X, W, b
41  // Output: Y
42  INPUT_TAGS(INPUT, FILTER, BIAS);
43 };
44 
45 } // namespace caffe2
46 
47 #endif // CAFFE2_MOBILE
48 
49 #endif // CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...