1 #ifndef CAFFE2_OPERATORS_ORDER_SWITCH_OPS_H_ 2 #define CAFFE2_OPERATORS_ORDER_SWITCH_OPS_H_ 6 #include "caffe2/core/operator.h" 7 #include "caffe2/utils/math.h" 15 template <
typename T,
class Context>
18 USE_OPERATOR_CONTEXT_FUNCTIONS;
22 bool RunOnDevice()
override {
23 const auto& X =
Input(0);
25 const int ndim = X.dim();
26 CAFFE_ENFORCE_GE(ndim, 3);
27 const int N = X.dim32(0);
28 const int C = X.dim32(ndim - 1);
29 std::vector<int64_t> Y_dims(ndim);
33 for (
int i = 2; i < ndim; ++i) {
34 Y_dims[i] = X.dim32(i - 1);
37 auto* Y = Output(0, Y_dims, at::dtype<T>());
41 math::NHWC2NCHW<T, Context>(
46 Y->template mutable_data<T>(),
52 template <
typename T,
class Context>
55 USE_OPERATOR_CONTEXT_FUNCTIONS;
59 bool RunOnDevice()
override {
60 const auto& X =
Input(0);
62 const int ndim = X.dim();
63 CAFFE_ENFORCE_GE(ndim, 3);
64 const int N = X.dim32(0);
65 const int C = X.dim32(1);
66 std::vector<int64_t> Y_dims(ndim);
70 for (
int i = 1; i < ndim - 1; ++i) {
71 Y_dims[i] = X.dim32(i + 1);
74 auto* Y = Output(0, Y_dims, at::dtype<T>());
78 math::NCHW2NHWC<T, Context>(
83 Y->template mutable_data<T>(),
91 #endif // CAFFE2_OPERATORS_ORDER_SWITCH_OPS_H_ const Tensor & Input(int idx, DeviceType type=Context::GetDeviceType())
Retrieve a non-owning reference to the input at position 'idx' for this operator. ...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...