blob: 766635dfa1a4371e0661cdfe9f767e6a27c75abe [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Georgios Pinitas11d84152021-04-28 10:20:18 +01002 * Copyright (c) 2016-2021 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000024#include "arm_compute/runtime/NEON/functions/NEDepthConvertLayer.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010025
Georgios Pinitas11d84152021-04-28 10:20:18 +010026#include "arm_compute/core/Validate.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010027
Georgios Pinitas7891a732021-08-20 21:39:25 +010028#include "src/cpu/operators/CpuCast.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029
30#include <utility>
31
Georgios Pinitas11d84152021-04-28 10:20:18 +010032namespace arm_compute
33{
34struct NEDepthConvertLayer::Impl
35{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010036 const ITensor *src{nullptr};
37 ITensor *dst{nullptr};
38 std::unique_ptr<cpu::CpuCast> op{nullptr};
Georgios Pinitas11d84152021-04-28 10:20:18 +010039};
40
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010041NEDepthConvertLayer::NEDepthConvertLayer() : _impl(std::make_unique<Impl>())
Georgios Pinitas11d84152021-04-28 10:20:18 +010042{
43}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010044NEDepthConvertLayer::NEDepthConvertLayer(NEDepthConvertLayer &&) = default;
Georgios Pinitas11d84152021-04-28 10:20:18 +010045NEDepthConvertLayer &NEDepthConvertLayer::operator=(NEDepthConvertLayer &&) = default;
46NEDepthConvertLayer::~NEDepthConvertLayer() = default;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047
Michele Di Giorgio3e570db2018-08-24 18:28:48 +010048void NEDepthConvertLayer::configure(const ITensor *input, ITensor *output, ConvertPolicy policy, uint32_t shift)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049{
Georgios Pinitas11d84152021-04-28 10:20:18 +010050 ARM_COMPUTE_UNUSED(shift);
51
52 _impl->src = input;
53 _impl->dst = output;
54
55 ARM_COMPUTE_ERROR_ON_NULLPTR(_impl->src, _impl->dst);
56 ARM_COMPUTE_ERROR_ON(shift != 0);
57
58 _impl->op = std::make_unique<cpu::CpuCast>();
59 _impl->op->configure(_impl->src->info(), _impl->dst->info(), policy);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010060}
Michele Di Giorgio3e570db2018-08-24 18:28:48 +010061
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010062Status
63NEDepthConvertLayer::validate(const ITensorInfo *input, const ITensorInfo *output, ConvertPolicy policy, uint32_t shift)
Michele Di Giorgio3e570db2018-08-24 18:28:48 +010064{
Georgios Pinitas11d84152021-04-28 10:20:18 +010065 ARM_COMPUTE_RETURN_ERROR_ON(shift != 0);
66 return cpu::CpuCast::validate(input, output, policy);
Michele Di Giorgio3e570db2018-08-24 18:28:48 +010067}
Georgios Pinitas11d84152021-04-28 10:20:18 +010068
69void NEDepthConvertLayer::run()
70{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010071 ITensorPack pack = {{ACL_SRC, _impl->src}, {ACL_DST, _impl->dst}};
Georgios Pinitas11d84152021-04-28 10:20:18 +010072 _impl->op->run(pack);
73}
74} // namespace arm_compute