1 #include "caffe2/mobile/contrib/arm-compute/core/context.h" 2 #include "caffe2/mobile/contrib/arm-compute/core/operator.h" 3 #include "caffe2/operators/concat_split_op.h" 13 bool RunOnDevice()
override;
15 arm_compute::GCDepthConcatenateLayer concat_layer_;
16 bool first_run_ =
true, second_run_ =
true;
17 std::vector<GLContext::deleted_unique_ptr<const GLTensor<T>>> inputs_;
18 int channelCount_ = 0;
25 CAFFE_ENFORCE(InputSize() <= 4 && InputSize() >= 2,
"Number \ 26 of input must be between 2 and 4.");
28 auto *X0blob = OperatorBase::Inputs()[0];
29 auto X0 = GLContext::getGLTensor<T>(X0blob);
31 inputs_.push_back(std::move(X0));
34 int N = inputs_[0]->dim32(0);
35 int channels = inputs_[0]->dim32(1);
36 int height = inputs_[0]->dim32(2);
37 int width = inputs_[0]->dim32(3);
38 std::vector<const Blob*> inputsBlob;
39 inputsBlob.push_back(X0blob);
42 channelCount_ = channels;
43 for (
int i = 1; i < Inputs().size(); ++i) {
44 auto *Xblob = OperatorBase::Inputs()[i];
45 auto X = GLContext::getGLTensor<T>(Xblob);
46 CAFFE_ENFORCE_EQ(N, X->dim32(0), X->dim32(0));
47 CAFFE_ENFORCE_EQ(height, X->dim32(2), X->dim32(2));
48 CAFFE_ENFORCE_EQ(width, X->dim32(3), X->dim32(3));
49 channelCount_ += X->dim32(1);
50 inputs_.push_back(std::move(X));
54 for (
int i = 1; i < Inputs().size(); ++i) {
55 auto *Xblob = OperatorBase::Inputs()[i];
56 inputsBlob.push_back(Xblob);
58 std::vector<int> output_dims = {N, channelCount_, height, width};
60 OperatorBase::Outputs()[0]->template GetMutable<GLTensor<T>>();
63 Y->Resize(output_dims);
65 std::vector<arm_compute::IGCTensor*> inputsGC;
66 for (
int i = 0; i < inputs_.size(); ++i) {
67 inputsGC.push_back(inputs_[i]->get_underlying());
69 concat_layer_.configure(inputsGC, Y->get_underlying());
71 for (
int i = 0; i < inputs_.size(); ++i) {
72 auto* X = inputs_[i].get();
73 auto* Xblob = inputsBlob[i];
74 X->lazy_allocate(Xblob, second_run_,
true);
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...