This commit removes backend dependency in `Permute` such as `Window`, `Iterator` and `ICLTensor`...
Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
#include "util/feature/nchw/View.h"
#include <misc/feature/IndexIterator.h>
-// TODO Remove these dependencies to arm_compute lib
-#include "backend/acl_cl/operand/ICLTensor.h"
-#include <arm_compute/core/Window.h>
-#include <arm_compute/core/Helpers.h>
-
namespace neurun
{
namespace exec
auto input_buffer = tensor.buffer();
auto rank = _shape.rank();
- auto input_cl = dynamic_cast<::neurun::backend::acl_cl::operand::ICLTensor *>(&tensor);
switch (rank)
{
case 0:
}
case 2:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
- Window window;
- window.use_tensor_dimensions(input_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(input_cl->handle(), window);
-
- int output_width = _shape.asMatrix().W;
+ auto matrix_shape = _shape.asMatrix();
- const auto &y = window[Window::DimY];
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < matrix_shape.H; ++h)
{
- memcpy(_output_buffer + h * output_width, it.ptr(), output_width * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, 0};
+ memcpy(_output_buffer + h * matrix_shape.W, input_buffer + tensor.calcOffset(coord),
+ matrix_shape.W * sizeof(float));
}
break;
}
case 3:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
- const int32_t height_width = _shape.dim(1) * _shape.dim(2);
+ const int32_t depth = _shape.dim(0);
+ const int32_t height = _shape.dim(1);
const int32_t width = _shape.dim(2);
- Window window;
- window.use_tensor_dimensions(input_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(input_cl->handle(), window);
-
- const auto &z = window[Window::DimZ];
- const auto &y = window[Window::DimY];
- for (auto c = z.start(); c < z.end(); c += z.step(), it.increment(Window::DimZ))
+ for (auto c = 0; c < depth; ++c)
{
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < height; ++h)
{
- memcpy(_output_buffer + c * height_width + h * width, it.ptr(), width * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, c};
+ memcpy(_output_buffer + c * height * width + h * width,
+ input_buffer + tensor.calcOffset(coord), width * sizeof(float));
}
}
break;
{
auto feature = _shape.asFeature();
- // TODO Fix this workaround (We may need codegen::operand::Object instead of ITensor)
- const util::feature::nchw::View<float> from{input_cl};
+ const util::feature::nchw::View<float> from{&tensor};
util::feature::nhwc::View<float> into{feature, reinterpret_cast<float *>(_output_buffer),
_output_size};
#include "cpp14/memory.h"
#include "util/feature/nchw/View.h"
#include "util/feature/nhwc/Reader.h"
+#include "util/feature/Coordinate4D.h"
#include <misc/feature/IndexIterator.h>
-// TODO Remove these dependencies to arm_compute lib
-#include "backend/acl_cl/operand/ICLTensor.h"
-#include <arm_compute/core/Window.h>
-#include <arm_compute/core/Helpers.h>
-
namespace neurun
{
namespace exec
auto output_buffer = tensor.buffer();
auto rank = _shape.rank();
- auto output_cl = dynamic_cast<::neurun::backend::acl_cl::operand::ICLTensor *>(&tensor);
switch (rank)
{
case 0:
}
case 2:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
auto matrix_shape = _shape.asMatrix();
- Window window;
- window.use_tensor_dimensions(output_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(output_cl->handle(), window);
-
- const auto &y = window[Window::DimY];
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < matrix_shape.H; ++h)
{
- memcpy(it.ptr(), _input_buffer + h * matrix_shape.W, matrix_shape.W * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, 0};
+ memcpy(output_buffer + tensor.calcOffset(coord), _input_buffer + h * matrix_shape.W,
+ matrix_shape.W * sizeof(float));
}
break;
}
case 3:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
- const int32_t height_width = _shape.dim(1) * _shape.dim(2);
+ const int32_t depth = _shape.dim(0);
+ const int32_t height = _shape.dim(1);
const int32_t width = _shape.dim(2);
- Window window;
- window.use_tensor_dimensions(output_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(output_cl->handle(), window);
-
- const auto &z = window[Window::DimZ];
- const auto &y = window[Window::DimY];
- for (auto c = z.start(); c < z.end(); c += z.step(), it.increment(Window::DimZ))
+ for (auto c = 0; c < depth; ++c)
{
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < height; ++h)
{
- memcpy(it.ptr(), _input_buffer + c * height_width + h * width, width * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, c};
+ memcpy(output_buffer + tensor.calcOffset(coord),
+ _input_buffer + c * height * width + h * width, width * sizeof(float));
}
}
break;
const util::feature::nhwc::Reader<float> from{
feature, reinterpret_cast<const float *>(_input_buffer), _input_size};
- util::feature::nchw::View<float> into{output_cl};
+ util::feature::nchw::View<float> into{&tensor};
- // TODO Fix this workaround (We may need codegen::operand::Object instead of ITensor)
::nnfw::misc::feature::iterate(feature)
<< [&](uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) {
const auto value = from.at(batch, ch, row, col);
#include "util/feature/nhwc/Reader.h"
#include "util/feature/nhwc/View.h"
#include "util/feature/nchw/View.h"
+#include "util/feature/Coordinate4D.h"
#include <misc/feature/IndexIterator.h>
-// TODO Remove these dependencies to arm_compute lib
-#include <arm_compute/runtime/CL/CLScheduler.h>
-#include "backend/acl_cl/operand/CLTensor.h"
-
namespace neurun
{
namespace kernel
auto output_buffer = tensor.buffer();
auto output_size = tensor.total_size();
-
- auto output_cl = dynamic_cast<::neurun::backend::acl_cl::operand::ICLTensor *>(&tensor);
switch (rank)
{
case 0:
}
case 2:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
auto matrix_shape = _shape.asMatrix();
- Window window;
- window.use_tensor_dimensions(output_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(output_cl->handle(), window);
-
- const auto &y = window[Window::DimY];
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < matrix_shape.H; ++h)
{
- memcpy(it.ptr(), input_buffer + h * matrix_shape.W, matrix_shape.W * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, 0};
+ memcpy(output_buffer + tensor.calcOffset(coord), input_buffer + h * matrix_shape.W,
+ matrix_shape.W * sizeof(float));
}
break;
}
case 3:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
- const int32_t height_width = _shape.dim(1) * _shape.dim(2);
+ const int32_t depth = _shape.dim(0);
+ const int32_t height = _shape.dim(1);
const int32_t width = _shape.dim(2);
- Window window;
- window.use_tensor_dimensions(output_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(output_cl->handle(), window);
-
- const auto &z = window[Window::DimZ];
- const auto &y = window[Window::DimY];
- for (auto c = z.start(); c < z.end(); c += z.step(), it.increment(Window::DimZ))
+ for (auto c = 0; c < depth; ++c)
{
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < height; ++h)
{
- memcpy(it.ptr(), input_buffer + c * height_width + h * width,
- width * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, c};
+ memcpy(output_buffer + tensor.calcOffset(coord),
+ input_buffer + c * height * width + h * width, width * sizeof(float));
}
}
break;
const util::feature::nhwc::Reader<float> from{
feature, reinterpret_cast<const float *>(input_buffer), input_size};
- util::feature::nchw::View<float> into{output_cl};
+ util::feature::nchw::View<float> into{&tensor};
::nnfw::misc::feature::iterate(feature)
<< [&](uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) {
auto output_buffer = output_tensor->buffer();
auto output_size = output_tensor->total_size();
- auto input_cl = dynamic_cast<::neurun::backend::acl_cl::operand::ICLTensor *>(&tensor);
switch (rank)
{
case 0:
}
case 2:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
- Window window;
- window.use_tensor_dimensions(input_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(input_cl->handle(), window);
-
- int output_width = _shape.asMatrix().W;
+ auto matrix_shape = _shape.asMatrix();
- const auto &y = window[Window::DimY];
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < matrix_shape.H; ++h)
{
- memcpy(output_buffer + h * output_width, it.ptr(), output_width * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, 0};
+ memcpy(output_buffer + h * matrix_shape.W, input_buffer + tensor.calcOffset(coord),
+ matrix_shape.W * sizeof(float));
}
break;
}
case 3:
{
- using ::arm_compute::Window;
- using ::arm_compute::Iterator;
-
- const int32_t height_width = _shape.dim(1) * _shape.dim(2);
+ const int32_t depth = _shape.dim(0);
+ const int32_t height = _shape.dim(1);
const int32_t width = _shape.dim(2);
- Window window;
- window.use_tensor_dimensions(input_cl->info()->tensor_shape(), Window::DimY);
-
- Iterator it(input_cl->handle(), window);
-
- const auto &z = window[Window::DimZ];
- const auto &y = window[Window::DimY];
- for (auto c = z.start(); c < z.end(); c += z.step(), it.increment(Window::DimZ))
+ for (auto c = 0; c < depth; ++c)
{
- for (auto h = y.start(); h < y.end(); h += y.step(), it.increment(Window::DimY))
+ for (auto h = 0; h < height; ++h)
{
- memcpy(output_buffer + c * height_width + h * width, it.ptr(),
- width * sizeof(float));
+ neurun::util::feature::Coordinate4D coord{0, h, 0, c};
+ memcpy(output_buffer + c * height * width + h * width,
+ input_buffer + tensor.calcOffset(coord), width * sizeof(float));
}
}
break;
{
auto feature = _shape.asFeature();
- const util::feature::nchw::View<float> from{input_cl};
+ const util::feature::nchw::View<float> from{&tensor};
util::feature::nhwc::View<float> into{feature, reinterpret_cast<float *>(output_buffer),
output_size};