for (auto input : _input_allocs)
{
- assert(_output_alloc->layout() == input->layout());
- assert(matchSizeExceptAxis(_output_alloc, input, _axis));
- axis_sum += input->dimension(_axis);
+ assert(_output_alloc->ptr()->layout() == input->ptr()->layout());
+ assert(matchSizeExceptAxis(_output_alloc->ptr(), input->ptr(), _axis));
+ axis_sum += input->ptr()->dimension(_axis);
}
- assert(_output_alloc->dimension(_axis) == axis_sum);
+ assert(_output_alloc->ptr()->dimension(_axis) == axis_sum);
}
VERBOSE(Concat_RUN) << "START Concat" << std::endl;
auto &queue = ::arm_compute::CLScheduler::get().queue();
- _output_alloc->map(queue);
-
- for (auto input : _input_allocs)
- {
- input->map(queue);
-
- for (int32_t i = 0; i < input->info()->dimension(0); i++)
+ auto outout_fn = [&](::neurun::backend::operand::ITensor &out_tensor) {
+ for (auto input : _input_allocs)
{
- for (int32_t j = 0; j < input->info()->dimension(1); j++)
- {
- for (int32_t k = 0; k < input->info()->dimension(2); k++)
+ auto &out_cl_tensor =
+ static_cast<::neurun::backend::acl_cl::operand::ICLTensor &>(out_tensor);
+ auto input_fn = [&](::neurun::backend::operand::ITensor &in_tensor) {
+ auto &in_cl_tensor =
+ static_cast<::neurun::backend::acl_cl::operand::ICLTensor &>(in_tensor);
+ for (int32_t i = 0; i < in_cl_tensor.info()->dimension(0); i++)
{
- for (int32_t l = 0; l < input->info()->dimension(3); l++)
+ for (int32_t j = 0; j < in_cl_tensor.info()->dimension(1); j++)
{
- int32_t io = (_axis == 0) ? axis_offset : 0;
- int32_t jo = (_axis == 1) ? axis_offset : 0;
- int32_t ko = (_axis == 2) ? axis_offset : 0;
- int32_t lo = (_axis == 3) ? axis_offset : 0;
- T value = *reinterpret_cast<T *>(input->handle()->ptr_to_element({i, j, k, l}));
- *reinterpret_cast<T *>(_output_alloc->handle()->ptr_to_element(
- {i + io, j + jo, k + ko, l + lo})) = value;
+ for (int32_t k = 0; k < in_cl_tensor.info()->dimension(2); k++)
+ {
+ for (int32_t l = 0; l < in_cl_tensor.info()->dimension(3); l++)
+ {
+ int32_t io = (_axis == 0) ? axis_offset : 0;
+ int32_t jo = (_axis == 1) ? axis_offset : 0;
+ int32_t ko = (_axis == 2) ? axis_offset : 0;
+ int32_t lo = (_axis == 3) ? axis_offset : 0;
+ T value =
+ *reinterpret_cast<T *>(in_cl_tensor.handle()->ptr_to_element({i, j, k, l}));
+ *reinterpret_cast<T *>(out_cl_tensor.handle()->ptr_to_element(
+ {i + io, j + jo, k + ko, l + lo})) = value;
+ }
+ }
}
}
- }
+ if (_axis == 0)
+ axis_offset += in_cl_tensor.info()->dimension(0);
+ if (_axis == 1)
+ axis_offset += in_cl_tensor.info()->dimension(1);
+ if (_axis == 2)
+ axis_offset += in_cl_tensor.info()->dimension(2);
+ if (_axis == 3)
+ axis_offset += in_cl_tensor.info()->dimension(3);
+ };
+ input->access(input_fn);
}
- if (_axis == 0)
- axis_offset += input->info()->dimension(0);
- if (_axis == 1)
- axis_offset += input->info()->dimension(1);
- if (_axis == 2)
- axis_offset += input->info()->dimension(2);
- if (_axis == 3)
- axis_offset += input->info()->dimension(3);
-
- input->unmap(queue);
- }
- _output_alloc->unmap(queue);
+ };
+ _output_alloc->access(outout_fn);
}
VERBOSE(Concat_RUN) << "End Concat" << std::endl;
}
void ConcatLayer::configure(
- const std::vector<::neurun::backend::acl_cl::operand::ICLTensor *> &input_allocs, int32_t axis,
- ::neurun::backend::acl_cl::operand::ICLTensor *output_alloc)
+ const std::vector<::neurun::backend::acl_cl::operand::Object *> &input_allocs, int32_t axis,
+ ::neurun::backend::acl_cl::operand::Object *output_alloc)
{
_input_allocs = input_allocs;
_output_alloc = output_alloc;
// NHWC -> CWHN
// NCHW -> WHCN
_axis =
- ::neurun::backend::acl_common::ToARMComputeAxis(output_alloc->num_dimensions(), axis).value();
+ ::neurun::backend::acl_common::ToARMComputeAxis(_output_alloc->ptr()->num_dimensions(), axis)
+ .value();
- _input_type = input_allocs[0]->data_type();
+ _input_type = input_allocs[0]->ptr()->data_type();
}
void ConcatLayer::run()
#include <arm_compute/runtime/IFunction.h>
#include <arm_compute/core/Types.h>
-#include "operand/ICLTensor.h"
+#include "operand/Object.h"
namespace neurun
{
ConcatLayer();
public:
- void configure(const std::vector<::neurun::backend::acl_cl::operand::ICLTensor *> &input_allocs,
+ void configure(const std::vector<::neurun::backend::acl_cl::operand::Object *> &input_allocs,
int32_t axis /* NNAPI tensor axis from NHWC order */,
- ::neurun::backend::acl_cl::operand::ICLTensor *output_alloc);
+ ::neurun::backend::acl_cl::operand::Object *output_alloc);
void run();
template <typename T> bool concatenate();
private:
- std::vector<::neurun::backend::acl_cl::operand::ICLTensor *> _input_allocs;
- ::neurun::backend::acl_cl::operand::ICLTensor *_output_alloc;
+ std::vector<::neurun::backend::acl_cl::operand::Object *> _input_allocs;
+ ::neurun::backend::acl_cl::operand::Object *_output_alloc;
int32_t _axis;
arm_compute::DataType _input_type;
};