Caffe2 - C++ API
A deep learning, cross platform ML framework
conv_transpose_op_mobile.h
1 
17 #ifndef CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
18 #define CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
19 
20 #include "caffe2/core/common.h"
21 
22 #ifndef CAFFE2_MOBILE
23 #error "mobile build state not defined"
24 #endif
25 
26 #if CAFFE2_MOBILE
27 
28 #include "caffe2/core/context.h"
29 #include "caffe2/core/operator.h"
30 #include "caffe2/operators/conv_transpose_unpool_op_base.h"
31 
32 namespace caffe2 {
33 
34 template <typename T, class Context>
35 class ConvTransposeMobileOp final : public ConvTransposeUnpoolBase<Context> {
36  public:
37  USE_CONV_TRANSPOSE_UNPOOL_BASE_FUNCTIONS(Context);
38  ConvTransposeMobileOp(const OperatorDef& operator_def, Workspace* ws)
39  : ConvTransposeUnpoolBase<Context>(operator_def, ws) {
40  OPERATOR_NEEDS_FEATURE(order_ == StorageOrder::NCHW, "Only NCHW order is supported right now.");
41  OPERATOR_NEEDS_FEATURE(
42  this->pad_l() == 0, "operator does not handle row width padding");
43  OPERATOR_NEEDS_FEATURE(
44  this->pad_r() == 0, "operator does not handle row width padding");
45  OPERATOR_NEEDS_FEATURE(this->stride_w() <= 4, "stride width must be <= 4");
46  }
47 
48  bool RunOnDeviceWithOrderNCHW() override;
49  bool RunOnDeviceWithOrderNHWC() override;
50 
51  private:
52  // We store a numThreasds per-worker tiles of Y, and numThreads per-worker threadBuffer for the
53  // gemm output, laid out in that order.
54  TensorCPU threadBuffer_;
55 
56  // Input: X, W, b
57  // Output: Y
58  INPUT_TAGS(INPUT, FILTER, BIAS);
59 };
60 
61 } // namespace caffe2
62 
63 #endif // CAFFE2_MOBILE
64 
65 #endif // CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
Copyright (c) 2016-present, Facebook, Inc.