summaryrefslogtreecommitdiff
path: root/runtimes/neurun/src/kernel/acl_cl
diff options
context:
space:
mode:
Diffstat (limited to 'runtimes/neurun/src/kernel/acl_cl')
-rw-r--r--runtimes/neurun/src/kernel/acl_cl/CLFunction.h55
-rw-r--r--runtimes/neurun/src/kernel/acl_cl/CMakeLists.txt13
-rw-r--r--runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc159
-rw-r--r--runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h67
4 files changed, 0 insertions, 294 deletions
diff --git a/runtimes/neurun/src/kernel/acl_cl/CLFunction.h b/runtimes/neurun/src/kernel/acl_cl/CLFunction.h
deleted file mode 100644
index f34210c8a..000000000
--- a/runtimes/neurun/src/kernel/acl_cl/CLFunction.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __NEURUN_KERNEL_ACL_CL_CL_FUNCTION_H__
-#define __NEURUN_KERNEL_ACL_CL_CL_FUNCTION_H__
-
-#include "exec/interface/IFunction.h"
-#include <arm_compute/runtime/IFunction.h>
-#include <memory>
-
-namespace neurun
-{
-namespace kernel
-{
-namespace acl_cl
-{
-
-class CLFunction : public ::neurun::exec::IFunction
-{
-public:
- CLFunction() = delete;
-
-public:
- CLFunction(std::unique_ptr<::arm_compute::IFunction> &&func)
- : _func(std::forward<std::unique_ptr<::arm_compute::IFunction>>(func))
- {
- // DO NOTHING
- }
-
-public:
- void run() override { _func->run(); }
- void prepare() override { _func->prepare(); }
-
-private:
- std::unique_ptr<::arm_compute::IFunction> _func;
-};
-
-} // namespace acl_cl
-} // namespace kernel
-} // namespace neurun
-
-#endif // __NEURUN_KERNEL_ACL_CL_CL_FUNCTION_H__
diff --git a/runtimes/neurun/src/kernel/acl_cl/CMakeLists.txt b/runtimes/neurun/src/kernel/acl_cl/CMakeLists.txt
deleted file mode 100644
index 0658effea..000000000
--- a/runtimes/neurun/src/kernel/acl_cl/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-file(GLOB SOURCES "*.cc")
-
-add_library(${LIB_NEURUN_KERNEL_ACL_CL} STATIC ${SOURCES})
-
-target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PUBLIC ${NNFW_INCLUDE_DIR})
-target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PUBLIC ${NEURUN_INCLUDE_DIR})
-
-target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} arm_compute)
-target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} nnfw_lib_misc)
-
-set_target_properties(${LIB_NEURUN_KERNEL_ACL_CL} PROPERTIES POSITION_INDEPENDENT_CODE ON)
-set_target_properties(${LIB_NEURUN_KERNEL_ACL_CL} PROPERTIES OUTPUT_NAME kernel_acl_cl)
-install(TARGETS ${LIB_NEURUN_KERNEL_ACL_CL} DESTINATION lib/neurun)
diff --git a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc b/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc
deleted file mode 100644
index 3844317ab..000000000
--- a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ConcatLayer.h"
-
-#include <arm_compute/runtime/CL/CLScheduler.h>
-
-#include "util/feature/nchw/View.h"
-#include "util/logging.h"
-
-namespace
-{
-
-bool matchSizeExceptAxis(const ::neurun::backend::acl_cl::operand::ICLTensor *t1,
- const ::neurun::backend::acl_cl::operand::ICLTensor *t2, uint32_t axis)
-{
- assert(t1->num_dimensions() <= 4);
- assert(t2->num_dimensions() <= 4);
-
- for (uint32_t i = 0; i < 4; i++)
- {
- if (axis == i)
- continue;
- if (t1->dimension(i) != t2->dimension(i))
- return false;
- }
- return true;
-}
-
-} // namespace {anonymous}
-
-namespace neurun
-{
-namespace kernel
-{
-namespace acl_cl
-{
-
-ConcatLayer::ConcatLayer()
- : _input_allocs(), _output_alloc(nullptr), _axis(0), _input_type(OperandType::SCALAR_FLOAT32)
-{
- // DO NOTHING
-}
-
-bool ConcatLayer::concatenationFloat32()
-{
- // Input and output size check
- {
- // NOTE Support only tensor with dimension 4 or less
-
- uint32_t axis_sum = 0;
-
- for (auto input : _input_allocs)
- {
- assert(matchSizeExceptAxis(_output_alloc, input, _axis));
- axis_sum += input->dimension(_axis);
- }
-
- assert(_output_alloc->dimension(_axis) == axis_sum);
- }
-
- VERBOSE(Concat_RUN) << "START Concat" << std::endl;
-
- // Perform operation
- {
- uint32_t axis_offset = 0;
-
- auto &queue = ::arm_compute::CLScheduler::get().queue();
-
- _output_alloc->map(queue);
- util::feature::nchw::View<float> output_view{_output_alloc};
-
- for (auto input : _input_allocs)
- {
- input->map(queue);
- const util::feature::nchw::View<float> input_reader{input};
-
- for (uint32_t n = 0; n < input_reader.shape().N; n++)
- {
- for (uint32_t c = 0; c < input_reader.shape().C; c++)
- {
- for (uint32_t h = 0; h < input_reader.shape().H; h++)
- {
- for (uint32_t w = 0; w < input_reader.shape().W; w++)
- {
- uint32_t no = (_axis == 3) ? axis_offset : 0;
- uint32_t co = (_axis == 2) ? axis_offset : 0;
- uint32_t ho = (_axis == 1) ? axis_offset : 0;
- uint32_t wo = (_axis == 0) ? axis_offset : 0;
- output_view.at(n + no, c + co, h + ho, w + wo) = input_reader.at(n, c, h, w);
- }
- }
- }
- }
- if (_axis == 3)
- axis_offset += input_reader.shape().N;
- if (_axis == 2)
- axis_offset += input_reader.shape().C;
- if (_axis == 1)
- axis_offset += input_reader.shape().H;
- if (_axis == 0)
- axis_offset += input_reader.shape().W;
-
- input->unmap(queue);
- }
- _output_alloc->unmap(queue);
- }
-
- VERBOSE(Concat_RUN) << "End Concat" << std::endl;
-
- return true;
-}
-
-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)
-{
- _input_allocs = input_allocs;
- _output_alloc = output_alloc;
-
- assert(axis < 4);
-
- // This map converts NHWC to NCHW(reversed)
- // NHWC -> WHCN
- static const uint32_t axis_map[] = {3, 1, 0, 2};
- _axis = axis_map[axis];
-
- // TODO Support Quant8
- _input_type = OperandType::TENSOR_FLOAT32;
-}
-
-void ConcatLayer::run()
-{
- if (_input_type == OperandType::TENSOR_FLOAT32)
- {
- concatenationFloat32();
- }
- else if (_input_type == OperandType::TENSOR_QUANT8_ASYMM)
- {
- throw std::runtime_error("NYI - concatenationQuant8()");
- }
-}
-
-} // namespace acl_cl
-} // namespace kernel
-} // namespace neurun
diff --git a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h b/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h
deleted file mode 100644
index d468a6dfb..000000000
--- a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __NEURUN_KERNEL_ACL_CL_CONCAT_LAYER_H__
-#define __NEURUN_KERNEL_ACL_CL_CONCAT_LAYER_H__
-
-#include <NeuralNetworks.h>
-
-#include <arm_compute/runtime/IFunction.h>
-
-#include "model/operand/DataType.h"
-#include "backend/acl_cl/operand/ICLTensor.h"
-
-using OperandType = neurun::model::operand::DataType;
-
-namespace neurun
-{
-namespace kernel
-{
-namespace acl_cl
-{
-
-//
-// neurun::kernel::acl_cl::ConcatLayer
-// A naive implementation of ConcatLayer for ACL
-//
-
-class ConcatLayer : public ::arm_compute::IFunction
-{
-public:
- ConcatLayer();
-
-public:
- void configure(const std::vector<::neurun::backend::acl_cl::operand::ICLTensor *> &input_allocs,
- int32_t axis /* NNAPI tensor axis from NHWC order */,
- ::neurun::backend::acl_cl::operand::ICLTensor *output_alloc);
-
- void run();
-
-private:
- bool concatenationFloat32();
-
-private:
- std::vector<::neurun::backend::acl_cl::operand::ICLTensor *> _input_allocs;
- ::neurun::backend::acl_cl::operand::ICLTensor *_output_alloc;
- int32_t _axis;
- OperandType _input_type;
-};
-
-} // namespace acl_cl
-} // namespace kernel
-} // namespace neurun
-
-#endif // __NEURUN_KERNEL_ACL_CL_CONCAT_LAYER_H__