1 #include "arm_compute/graph/Graph.h" 2 #include "arm_compute/graph/Nodes.h" 3 #include "caffe2/mobile/contrib/arm-compute/core/context.h" 4 #include "caffe2/mobile/contrib/arm-compute/core/operator.h" 6 #include "caffe2/operators/conv_op.h" 19 group_ == 1 || order_ == StorageOrder::NCHW,
20 "Group convolution only supports NCHW order right now.");
24 bool RunOnDevice()
override;
26 arm_compute::GCDirectConvolutionLayer conv_;
27 bool first_run_ =
true, second_run_ =
true;
28 GLContext::deleted_unique_ptr<const GLTensor<T>> X_, filter_, bias_;
33 auto *Xblob = OperatorBase::Inputs()[0];
34 auto *filterblob = OperatorBase::Inputs()[1];
35 auto *biasblob = OperatorBase::Inputs()[2];
38 X_ = GLContext::getGLTensor<T>(Xblob);
39 filter_ = GLContext::getGLTensor<T>(filterblob);
40 bias_ = GLContext::getGLTensor<T>(biasblob);
44 OperatorBase::Outputs()[0]->template GetMutable<GLTensor<T>>();
46 const int N = X_->dim32(0), H = X_->dim32(2), W = X_->dim32(3), C = X_->dim32(1);
48 CAFFE_ENFORCE_EQ(kernel_.size(), 2,
49 "Only 2d convolution is supported with ARM compute backend");
51 CAFFE_ENFORCE(X_->ndim(), filter_->ndim());
52 const int M = filter_->dim32(0);
53 CAFFE_ENFORCE(filter_->dim32(2) == kernel_h());
54 CAFFE_ENFORCE(filter_->dim32(3) == kernel_w());
55 CAFFE_ENFORCE(filter_->dim32(1) == C);
66 LOG(INFO) <<
"[C2DEBUG] dims of X " << X_->dims();
67 LOG(INFO) <<
"[C2DEBUG] dims of X(gctensor) " 68 << X_->get_underlying()->info()->dimension(3) <<
" " 69 << X_->get_underlying()->info()->dimension(2) <<
" " 70 << X_->get_underlying()->info()->dimension(1) <<
" " 71 << X_->get_underlying()->info()->dimension(0) <<
" " 73 LOG(INFO) <<
"[C2DEBUG] dims of Y " << Y->dims();
74 LOG(INFO) <<
"[C2DEBUG] dims of Y(gctensor) " 75 << Y->get_underlying()->info()->dimension(3) <<
" " 76 << Y->get_underlying()->info()->dimension(2) <<
" " 77 << Y->get_underlying()->info()->dimension(1) <<
" " 78 << Y->get_underlying()->info()->dimension(0) <<
" " 82 X_->get_underlying(), filter_->get_underlying(), bias_->get_underlying(),
84 arm_compute::PadStrideInfo(stride_[0], stride_[1], pads_[0], pads_[1]));
88 X_->lazy_allocate(Xblob, second_run_,
true);
89 filter_->lazy_allocate(filterblob, second_run_, second_run_);
90 bias_->lazy_allocate(biasblob, second_run_, second_run_);
93 if (Y->get_underlying() != X_->get_underlying()) {
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
void Resize(Ts...dim_source)
Resizes a tensor.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...