From c6f9510bcb754afaadfe9477ff85d6c55ffcf43b Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 30 Mar 2021 10:03:01 +0100 Subject: Remove Computer Vision generic interfaces and types Removes: - reference validation routines - CV related types and structures - CV related interfaces Signed-off-by: Georgios Pinitas Change-Id: I3a203da12d9b04c154059b190aeba18a611149a9 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5340 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/runtime/CL/CLDistribution1D.cpp | 61 ---------- src/runtime/CL/CLHOG.cpp | 84 -------------- src/runtime/CL/CLLut.cpp | 99 ---------------- src/runtime/CL/CLLutAllocator.cpp | 77 ------------- src/runtime/CL/CLMultiHOG.cpp | 52 --------- src/runtime/CL/CLMultiImage.cpp | 172 --------------------------- src/runtime/CL/CLPyramid.cpp | 127 -------------------- src/runtime/Distribution1D.cpp | 40 ------- src/runtime/HOG.cpp | 49 -------- src/runtime/ILutAllocator.cpp | 58 ---------- src/runtime/Lut.cpp | 75 ------------ src/runtime/LutAllocator.cpp | 50 -------- src/runtime/MultiHOG.cpp | 52 --------- src/runtime/MultiImage.cpp | 224 ------------------------------------ src/runtime/Pyramid.cpp | 117 ------------------- 15 files changed, 1337 deletions(-) delete mode 100644 src/runtime/CL/CLDistribution1D.cpp delete mode 100644 src/runtime/CL/CLHOG.cpp delete mode 100644 src/runtime/CL/CLLut.cpp delete mode 100644 src/runtime/CL/CLLutAllocator.cpp delete mode 100644 src/runtime/CL/CLMultiHOG.cpp delete mode 100644 src/runtime/CL/CLMultiImage.cpp delete mode 100644 src/runtime/CL/CLPyramid.cpp delete mode 100644 src/runtime/Distribution1D.cpp delete mode 100644 src/runtime/HOG.cpp delete mode 100644 src/runtime/ILutAllocator.cpp delete mode 100644 src/runtime/Lut.cpp delete mode 100644 src/runtime/LutAllocator.cpp delete mode 100644 src/runtime/MultiHOG.cpp delete mode 100644 src/runtime/MultiImage.cpp delete mode 100644 src/runtime/Pyramid.cpp (limited to 'src/runtime') diff --git a/src/runtime/CL/CLDistribution1D.cpp b/src/runtime/CL/CLDistribution1D.cpp deleted file mode 100644 index 91d67cbd0a..0000000000 --- a/src/runtime/CL/CLDistribution1D.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLDistribution1D.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLDistribution1D::CLDistribution1D(size_t num_bins, int32_t offset, uint32_t range) - : ICLDistribution1D(num_bins, offset, range), _mem(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, num_bins * sizeof(int32_t)) -{ -} - -void CLDistribution1D::map(bool blocking) -{ - ICLDistribution1D::map(CLScheduler::get().queue(), blocking); -} - -void CLDistribution1D::unmap() -{ - ICLDistribution1D::unmap(CLScheduler::get().queue()); -} - -uint32_t *CLDistribution1D::do_map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_mem.get() == nullptr); - return static_cast(q.enqueueMapBuffer(_mem, blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, size())); -} - -void CLDistribution1D::do_unmap(cl::CommandQueue &q) -{ - ARM_COMPUTE_ERROR_ON(_mem.get() == nullptr); - q.enqueueUnmapMemObject(_mem, _mapping); -} - -cl::Buffer &CLDistribution1D::cl_buffer() -{ - return _mem; -} diff --git a/src/runtime/CL/CLHOG.cpp b/src/runtime/CL/CLHOG.cpp deleted file mode 100644 index 6a02d8ff44..0000000000 --- a/src/runtime/CL/CLHOG.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2017-2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "arm_compute/runtime/CL/CLHOG.h" - -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLHOG::CLHOG() - : _info(), _buffer() -{ -} - -void CLHOG::init(const HOGInfo &input) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() != nullptr); - _info = input; - _buffer = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, info()->descriptor_size() * sizeof(float)); -} - -void CLHOG::free() -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - - _buffer = cl::Buffer(); -} - -const HOGInfo *CLHOG::info() const -{ - return &_info; -} - -const cl::Buffer &CLHOG::cl_buffer() const -{ - return _buffer; -} - -void CLHOG::map(bool blocking) -{ - ARM_COMPUTE_ERROR_ON(descriptor() != nullptr); - ICLHOG::map(CLScheduler::get().queue(), blocking); -} - -void CLHOG::unmap() -{ - ARM_COMPUTE_ERROR_ON(descriptor() == nullptr); - ICLHOG::unmap(CLScheduler::get().queue()); -} - -uint8_t *CLHOG::do_map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - return static_cast(q.enqueueMapBuffer(_buffer, blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, info()->descriptor_size() * sizeof(float))); -} - -void CLHOG::do_unmap(cl::CommandQueue &q) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - q.enqueueUnmapMemObject(_buffer, descriptor()); -} diff --git a/src/runtime/CL/CLLut.cpp b/src/runtime/CL/CLLut.cpp deleted file mode 100644 index eb9422cc37..0000000000 --- a/src/runtime/CL/CLLut.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLLut.h" - -#include "arm_compute/runtime/CL/CLScheduler.h" - -#include - -using namespace arm_compute; - -CLLut::CLLut() - : _allocator() -{ -} - -CLLut::CLLut(size_t num_elements, DataType data_type) - : _allocator() -{ - _allocator.init(num_elements, data_type); -} - -size_t CLLut::num_elements() const -{ - return _allocator.num_elements(); -} - -uint32_t CLLut::index_offset() const -{ - return (DataType::S16 == _allocator.type()) ? num_elements() / 2 : 0; -} - -size_t CLLut::size_in_bytes() const -{ - return _allocator.size(); -} - -DataType CLLut::type() const -{ - return _allocator.type(); -} - -const cl::Buffer &CLLut::cl_buffer() const -{ - return _allocator.cl_data(); -} - -void CLLut::clear() -{ - cl::CommandQueue &q = CLScheduler::get().queue(); - uint8_t *data = _allocator.map(q, true /* blocking */); - std::memset(data, 0, size_in_bytes()); - _allocator.unmap(q, data); -} - -ILutAllocator *CLLut::allocator() -{ - return &_allocator; -} - -void CLLut::map(bool blocking) -{ - ICLLut::map(CLScheduler::get().queue(), blocking); -} - -void CLLut::unmap() -{ - ICLLut::unmap(CLScheduler::get().queue()); -} - -uint8_t *CLLut::do_map(cl::CommandQueue &q, bool blocking) -{ - return _allocator.map(q, blocking); -} - -void CLLut::do_unmap(cl::CommandQueue &q) -{ - _allocator.unmap(q, buffer()); -} diff --git a/src/runtime/CL/CLLutAllocator.cpp b/src/runtime/CL/CLLutAllocator.cpp deleted file mode 100644 index d690cf2f1d..0000000000 --- a/src/runtime/CL/CLLutAllocator.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLLutAllocator.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLLutAllocator::CLLutAllocator() - : _buffer(), _mapping(nullptr) -{ -} - -uint8_t *CLLutAllocator::data() -{ - return _mapping; -} - -const cl::Buffer &CLLutAllocator::cl_data() const -{ - return _buffer; -} - -uint8_t *CLLutAllocator::map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - return static_cast(q.enqueueMapBuffer(_buffer, blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, size())); -} - -void CLLutAllocator::unmap(cl::CommandQueue &q, uint8_t *mapping) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - q.enqueueUnmapMemObject(_buffer, mapping); -} - -void CLLutAllocator::allocate() -{ - _buffer = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size()); -} - -uint8_t *CLLutAllocator::lock() -{ - ARM_COMPUTE_ERROR_ON(_mapping != nullptr); - cl::CommandQueue q = CLScheduler::get().queue(); - _mapping = map(q, true); - return _mapping; -} - -void CLLutAllocator::unlock() -{ - ARM_COMPUTE_ERROR_ON(_mapping == nullptr); - cl::CommandQueue q = CLScheduler::get().queue(); - unmap(q, _mapping); - _mapping = nullptr; -} diff --git a/src/runtime/CL/CLMultiHOG.cpp b/src/runtime/CL/CLMultiHOG.cpp deleted file mode 100644 index 28a802ca1e..0000000000 --- a/src/runtime/CL/CLMultiHOG.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLMultiHOG.h" - -#include "arm_compute/core/CL/ICLHOG.h" -#include "arm_compute/core/Error.h" - -using namespace arm_compute; - -CLMultiHOG::CLMultiHOG(size_t num_models) - : _num_models(num_models), _model() -{ - _model.resize(_num_models); -} - -size_t CLMultiHOG::num_models() const -{ - return _num_models; -} - -ICLHOG *CLMultiHOG::cl_model(size_t index) -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} - -const ICLHOG *CLMultiHOG::cl_model(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} diff --git a/src/runtime/CL/CLMultiImage.cpp b/src/runtime/CL/CLMultiImage.cpp deleted file mode 100644 index 28b3f854f2..0000000000 --- a/src/runtime/CL/CLMultiImage.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2016-2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLMultiImage.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Utils.h" -#include "arm_compute/runtime/ITensorAllocator.h" - -using namespace arm_compute; - -CLMultiImage::CLMultiImage() - : _info(), _plane() -{ -} - -const MultiImageInfo *CLMultiImage::info() const -{ - return &_info; -} - -void CLMultiImage::init(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, false); -} - -void CLMultiImage::init_auto_padding(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, true); -} - -void CLMultiImage::internal_init(unsigned int width, unsigned int height, Format format, bool auto_padding) -{ - TensorShape shape = adjust_odd_shape(TensorShape{ width, height }, format); - TensorInfo info(shape, Format::U8); - - if(auto_padding) - { - info.auto_padding(); - } - - switch(format) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - TensorInfo info_full(shape, format); - - if(auto_padding) - { - info_full.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info_full); - break; - } - case Format::NV12: - case Format::NV21: - { - const TensorShape shape_uv88 = calculate_subsampled_shape(shape, Format::UV88); - TensorInfo info_uv88(shape_uv88, Format::UV88); - - if(auto_padding) - { - info_uv88.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_uv88); - break; - } - case Format::IYUV: - { - const TensorShape shape_sub2 = calculate_subsampled_shape(shape, Format::IYUV); - TensorInfo info_sub2(shape_sub2, Format::U8); - - if(auto_padding) - { - info_sub2.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_sub2); - std::get<2>(_plane).allocator()->init(info_sub2); - break; - } - case Format::YUV444: - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info); - std::get<2>(_plane).allocator()->init(info); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - _info.init(shape.x(), shape.y(), format); -} - -void CLMultiImage::allocate() -{ - switch(_info.format()) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - std::get<0>(_plane).allocator()->allocate(); - break; - case Format::NV12: - case Format::NV21: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - break; - case Format::IYUV: - case Format::YUV444: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - std::get<2>(_plane).allocator()->allocate(); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } -} - -CLImage *CLMultiImage::cl_plane(unsigned int index) -{ - return &_plane[index]; -} - -const CLImage *CLMultiImage::cl_plane(unsigned int index) const -{ - return &_plane[index]; -} diff --git a/src/runtime/CL/CLPyramid.cpp b/src/runtime/CL/CLPyramid.cpp deleted file mode 100644 index dfa542e73c..0000000000 --- a/src/runtime/CL/CLPyramid.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLPyramid.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" - -#include -#include - -using namespace arm_compute; - -CLPyramid::CLPyramid() - : _info(), _pyramid() -{ -} - -void CLPyramid::init(const PyramidInfo &info) -{ - internal_init(info, false); -} - -void CLPyramid::init_auto_padding(const PyramidInfo &info) -{ - internal_init(info, true); -} - -void CLPyramid::internal_init(const PyramidInfo &info, bool auto_padding) -{ - _info = info; - _pyramid.resize(_info.num_levels()); - - size_t w = _info.width(); - size_t h = _info.height(); - size_t ref_w = w; - size_t ref_h = h; - const bool is_orb_scale = (SCALE_PYRAMID_ORB == _info.scale()); - TensorShape tensor_shape = _info.tensor_shape(); - - // Note: Look-up table used by the OpenVX sample implementation - const std::array c_orbscale = - { - { - 0.5f, - SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB *SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB - } - }; - - for(size_t i = 0; i < _info.num_levels(); ++i) - { - TensorInfo tensor_info(tensor_shape, _info.format()); - - if(auto_padding) - { - tensor_info.auto_padding(); - } - - _pyramid[i].allocator()->init(tensor_info); - - if(is_orb_scale) - { - const float orb_scale = c_orbscale[(i + 1) % 4]; - w = std::ceil(ref_w * orb_scale); - h = std::ceil(ref_h * orb_scale); - - if(0 == ((i + 1) % 4)) - { - ref_w = w; - ref_h = h; - } - } - else - { - w = (w + 1) * _info.scale(); - h = (h + 1) * _info.scale(); - } - - // Update tensor_shape - tensor_shape.set(0, w); - tensor_shape.set(1, h); - } -} - -void CLPyramid::allocate() -{ - for(size_t i = 0; i < _info.num_levels(); ++i) - { - _pyramid[i].allocator()->allocate(); - } -} - -const PyramidInfo *CLPyramid::info() const -{ - return &_info; -} - -CLTensor *CLPyramid::get_pyramid_level(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _info.num_levels()); - - return &_pyramid[index]; -} diff --git a/src/runtime/Distribution1D.cpp b/src/runtime/Distribution1D.cpp deleted file mode 100644 index c19862ce62..0000000000 --- a/src/runtime/Distribution1D.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/Distribution1D.h" - -#include "arm_compute/core/Error.h" - -#include - -using namespace arm_compute; - -Distribution1D::Distribution1D(size_t num_bins, int32_t offset, uint32_t range) - : IDistribution1D(num_bins, offset, range), _data(num_bins) -{ -} - -uint32_t *Distribution1D::buffer() const -{ - return _data.data(); -} diff --git a/src/runtime/HOG.cpp b/src/runtime/HOG.cpp deleted file mode 100644 index 74922767f9..0000000000 --- a/src/runtime/HOG.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/HOG.h" - -#include "arm_compute/core/Error.h" - -using namespace arm_compute; - -HOG::HOG() - : IHOG(), _info(), _descriptor() -{ -} - -void HOG::init(const HOGInfo &input) -{ - _info = input; - _descriptor.resize(_info.descriptor_size()); -} - -float *HOG::descriptor() const -{ - return _descriptor.data(); -} - -const HOGInfo *HOG::info() const -{ - return &_info; -} diff --git a/src/runtime/ILutAllocator.cpp b/src/runtime/ILutAllocator.cpp deleted file mode 100644 index 8ffb0744ed..0000000000 --- a/src/runtime/ILutAllocator.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/ILutAllocator.h" - -#include "arm_compute/core/Utils.h" - -using namespace arm_compute; - -ILutAllocator::ILutAllocator() - : _num_elements(0), _data_type(DataType::U8) -{ -} - -void ILutAllocator::init(size_t num_elements, DataType data_type) -{ - // Init internal metadata - _num_elements = num_elements; - _data_type = data_type; - - // Allocate the image's memory - allocate(); -} - -size_t ILutAllocator::num_elements() const -{ - return _num_elements; -} - -DataType ILutAllocator::type() const -{ - return _data_type; -} - -size_t ILutAllocator::size() const -{ - return data_size_from_type(_data_type) * num_elements(); -} diff --git a/src/runtime/Lut.cpp b/src/runtime/Lut.cpp deleted file mode 100644 index 9c3d2d384d..0000000000 --- a/src/runtime/Lut.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/Lut.h" - -#include - -using namespace arm_compute; - -Lut::Lut() - : _allocator() -{ -} - -Lut::Lut(size_t num_elements, DataType data_type) - : _allocator() -{ - _allocator.init(num_elements, data_type); -} - -size_t Lut::num_elements() const -{ - return _allocator.num_elements(); -} - -uint32_t Lut::index_offset() const -{ - return (DataType::S16 == _allocator.type()) ? num_elements() / 2 : 0; -} - -size_t Lut::size_in_bytes() const -{ - return _allocator.size(); -} - -DataType Lut::type() const -{ - return _allocator.type(); -} - -uint8_t *Lut::buffer() const -{ - return _allocator.data(); -} - -void Lut::clear() -{ - ARM_COMPUTE_ERROR_ON(this->buffer() == nullptr); - std::memset(this->buffer(), 0, this->size_in_bytes()); -} - -ILutAllocator *Lut::allocator() -{ - return &_allocator; -} diff --git a/src/runtime/LutAllocator.cpp b/src/runtime/LutAllocator.cpp deleted file mode 100644 index cc0c24f89b..0000000000 --- a/src/runtime/LutAllocator.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/LutAllocator.h" - -using namespace arm_compute; - -LutAllocator::LutAllocator() - : _buffer() -{ -} - -uint8_t *LutAllocator::data() const -{ - return _buffer.data(); -} - -void LutAllocator::allocate() -{ - _buffer.resize(size()); -} - -uint8_t *LutAllocator::lock() -{ - return _buffer.data(); -} - -void LutAllocator::unlock() -{ -} diff --git a/src/runtime/MultiHOG.cpp b/src/runtime/MultiHOG.cpp deleted file mode 100644 index d68b755b27..0000000000 --- a/src/runtime/MultiHOG.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/MultiHOG.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/IMultiHOG.h" - -using namespace arm_compute; - -MultiHOG::MultiHOG(size_t num_models) - : _num_models(num_models), _model() -{ - _model.resize(_num_models); -} - -size_t MultiHOG::num_models() const -{ - return _num_models; -} - -IHOG *MultiHOG::model(size_t index) -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} - -const IHOG *MultiHOG::model(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} diff --git a/src/runtime/MultiImage.cpp b/src/runtime/MultiImage.cpp deleted file mode 100644 index 66e67ed8ba..0000000000 --- a/src/runtime/MultiImage.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/MultiImage.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Utils.h" -#include "arm_compute/runtime/TensorAllocator.h" - -using namespace arm_compute; - -MultiImage::MultiImage() - : _info(), _plane() -{ -} - -const MultiImageInfo *MultiImage::info() const -{ - return &_info; -} - -void MultiImage::init(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, false); -} - -void MultiImage::init_auto_padding(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, true); -} - -void MultiImage::internal_init(unsigned int width, unsigned int height, Format format, bool auto_padding) -{ - TensorShape shape = adjust_odd_shape(TensorShape{ width, height }, format); - TensorInfo info(shape, Format::U8); - - if(auto_padding) - { - info.auto_padding(); - } - - switch(format) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - TensorInfo info_full(shape, format); - - if(auto_padding) - { - info_full.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info_full); - break; - } - case Format::NV12: - case Format::NV21: - { - const TensorShape shape_uv88 = calculate_subsampled_shape(shape, Format::UV88); - TensorInfo info_uv88(shape_uv88, Format::UV88); - - if(auto_padding) - { - info_uv88.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_uv88); - break; - } - case Format::IYUV: - { - const TensorShape shape_sub2 = calculate_subsampled_shape(shape, Format::IYUV); - TensorInfo info_sub2(shape_sub2, Format::U8); - - if(auto_padding) - { - info_sub2.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_sub2); - std::get<2>(_plane).allocator()->init(info_sub2); - break; - } - case Format::YUV444: - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info); - std::get<2>(_plane).allocator()->init(info); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - _info.init(shape.x(), shape.y(), format); -} - -void MultiImage::allocate() -{ - switch(_info.format()) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - std::get<0>(_plane).allocator()->allocate(); - break; - case Format::NV12: - case Format::NV21: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - break; - case Format::IYUV: - case Format::YUV444: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - std::get<2>(_plane).allocator()->allocate(); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } -} - -void MultiImage::create_subimage(MultiImage *image, const Coordinates &coords, unsigned int width, unsigned int height) -{ - arm_compute::Format format = image->info()->format(); - TensorInfo info(width, height, Format::U8); - - switch(format) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F32: - case Format::F16: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - TensorInfo info_full(width, height, format); - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info_full); - break; - } - case Format::NV12: - case Format::NV21: - { - TensorInfo info_uv88(width / 2, height / 2, Format::UV88); - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<1>(_plane).allocator()->init(*dynamic_cast(image->plane(1))->allocator(), coords, info_uv88); - break; - } - case Format::IYUV: - { - TensorInfo info_sub2(width / 2, height / 2, Format::U8); - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<1>(_plane).allocator()->init(*dynamic_cast(image->plane(1))->allocator(), coords, info_sub2); - std::get<2>(_plane).allocator()->init(*dynamic_cast(image->plane(2))->allocator(), coords, info_sub2); - break; - } - case Format::YUV444: - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<1>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<2>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - _info.init(width, height, format); -} - -Image *MultiImage::plane(unsigned int index) -{ - return &_plane[index]; -} - -const Image *MultiImage::plane(unsigned int index) const -{ - return &_plane[index]; -} diff --git a/src/runtime/Pyramid.cpp b/src/runtime/Pyramid.cpp deleted file mode 100644 index 5664b5f899..0000000000 --- a/src/runtime/Pyramid.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/Pyramid.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" - -#include - -using namespace arm_compute; - -void Pyramid::init(const PyramidInfo &info) -{ - internal_init(info, false); -} - -void Pyramid::init_auto_padding(const PyramidInfo &info) -{ - internal_init(info, true); -} - -void Pyramid::internal_init(const PyramidInfo &info, bool auto_padding) -{ - _info = info; - _pyramid.resize(_info.num_levels()); - - size_t w = _info.width(); - size_t h = _info.height(); - size_t ref_w = w; - size_t ref_h = h; - bool is_orb_scale = (SCALE_PYRAMID_ORB == _info.scale()); - TensorShape tensor_shape = _info.tensor_shape(); - - // Note: Look-up table used by the OpenVX sample implementation - const std::array c_orbscale = { 0.5f, - SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB *SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB - }; - - for(size_t i = 0; i < _info.num_levels(); ++i) - { - TensorInfo tensor_info(tensor_shape, _info.format()); - - if(auto_padding) - { - tensor_info.auto_padding(); - } - - _pyramid[i].allocator()->init(tensor_info); - - if(is_orb_scale) - { - float orb_scale = c_orbscale[(i + 1) % 4]; - w = static_cast(std::ceil(static_cast(ref_w) * orb_scale)); - h = static_cast(std::ceil(static_cast(ref_h) * orb_scale)); - - if(0 == ((i + 1) % 4)) - { - ref_w = w; - ref_h = h; - } - } - else - { - w = (w + 1) * _info.scale(); - h = (h + 1) * _info.scale(); - } - - // Update tensor_shape - tensor_shape.set(0, w); - tensor_shape.set(1, h); - } -} - -void Pyramid::allocate() -{ - for(size_t i = 0; i < _info.num_levels(); ++i) - { - _pyramid[i].allocator()->allocate(); - } -} - -const PyramidInfo *Pyramid::info() const -{ - return &_info; -} - -Tensor *Pyramid::get_pyramid_level(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _info.num_levels()); - - return &_pyramid[index]; -} -- cgit v1.2.1