This commit makes ConcatLayers support NCHW frontend layout.
Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
auto fn = nnfw::cpp14::make_unique<::neurun::backend::acl_cl::kernel::ConcatLayer>();
- fn->configure(input_allocs, axis, output_alloc);
+ const auto rank = _ctx.at(ofm_index).shape().rank();
+ const auto frontend_layout = _current_subg_layout;
+ const auto backend_layout = output_alloc->ptr()->layout();
+ const auto fixed_axis =
+ acl_common::ToARMComputeAxis(rank, axis, frontend_layout, backend_layout).value();
+
+ fn->configure(input_allocs, fixed_axis, output_alloc);
auto acl_fn = asAclFunction(std::move(fn));
#include <arm_compute/runtime/CL/CLScheduler.h>
-#include <Swizzle.h>
-
#include "util/feature/nchw/View.h"
#include "util/logging.h"
// TODO Handle when axis is negative
assert(axis >= 0);
- // This map converts to be reversed
- // NHWC -> CWHN
- // NCHW -> WHCN
- _axis =
- ::neurun::backend::acl_common::ToARMComputeAxis(_output_alloc->ptr()->num_dimensions(), axis)
- .value();
+ _axis = axis;
_input_type = input_allocs[0]->ptr()->data_type();
}
auto fn = nnfw::cpp14::make_unique<::neurun::backend::acl_neon::kernel::ConcatLayer>();
- fn->configure(input_allocs, axis, output_alloc);
+ const auto rank = _ctx.at(ofm_index).shape().rank();
+ const auto frontend_layout = _current_subg_layout;
+ const auto backend_layout = output_alloc->layout();
+ const auto fixed_axis =
+ acl_common::ToARMComputeAxis(rank, axis, frontend_layout, backend_layout).value();
+
+ fn->configure(input_allocs, fixed_axis, output_alloc);
auto acl_fn = asAclFunction(std::move(fn));
#include "ConcatLayer.h"
-#include <Swizzle.h>
-
-#include "util/feature/nchw/View.h"
#include "util/logging.h"
namespace
{
uint32_t axis_offset = 0;
- util::feature::nchw::View<T> output_view{_output_alloc};
-
for (auto input : _input_allocs)
{
for (uint32_t i = 0; i < input->info()->dimension(0); i++)
// TODO Handle when axis is negative
assert(axis >= 0);
- // This map converts to be reversed
- // NHWC -> CWHN
- // NCHW -> WHCN
- _axis =
- ::neurun::backend::acl_common::ToARMComputeAxis(output_alloc->num_dimensions(), axis).value();
+ _axis = axis;
_input_type = input_allocs[0]->data_type();
}
{
const auto ofm_index{node.getOutputs().at(0)};
- const auto axis = node.param().axis;
+ const auto rank = _ctx.at(ofm_index).shape().rank();
+ const auto axis =
+ ::neurun::backend::cpu::kernel::getAxis(rank, node.param().axis, _current_subg_layout);
const auto ofm_backend_shape =
::neurun::backend::cpu::kernel::getShape(_ctx.at(ofm_index), _current_subg_layout);
return nnfw::cker::GetShape(raw_shape);
}
+inline int32_t getAxis(uint32_t rank, int32_t axis, ::neurun::model::Layout frontend_layout)
+{
+ auto ret = axis;
+
+ if (axis < 0)
+ {
+ ret += rank;
+ }
+
+ // NCHW -> NHWC
+ if (frontend_layout == ::neurun::model::Layout::NCHW)
+ {
+ int32_t permutation[4] = {0, 3, 1, 2};
+ ret = permutation[ret];
+ }
+
+ return ret;
+}
+
void QuantizeMultiplier(double double_multiplier, int32_t *quantized_multiplier, int *shift);
void GetQuantizedConvolutionMultiplier(const Shape &inputShape, const Shape &filterShape,