blob: 1ec32074a5e69356bfe3798f531cdfe41b607655 [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"
Georgios Pinitas7891a732021-08-20 21:39:25 +010027#include "src/cpu/operators/CpuCast.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028
29#include <utility>
30
Georgios Pinitas11d84152021-04-28 10:20:18 +010031namespace arm_compute
32{
33struct NEDepthConvertLayer::Impl
34{
35 const ITensor *src{ nullptr };
36 ITensor *dst{ nullptr };
37 std::unique_ptr<cpu::CpuCast> op{ nullptr };
38};
39
40NEDepthConvertLayer::NEDepthConvertLayer()
41 : _impl(std::make_unique<Impl>())
42{
43}
44NEDepthConvertLayer::NEDepthConvertLayer(NEDepthConvertLayer &&) = default;
45NEDepthConvertLayer &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
62Status NEDepthConvertLayer::validate(const ITensorInfo *input, const ITensorInfo *output, ConvertPolicy policy, uint32_t shift)
63{
Georgios Pinitas11d84152021-04-28 10:20:18 +010064 ARM_COMPUTE_RETURN_ERROR_ON(shift != 0);
65 return cpu::CpuCast::validate(input, output, policy);
Michele Di Giorgio3e570db2018-08-24 18:28:48 +010066}
Georgios Pinitas11d84152021-04-28 10:20:18 +010067
68void NEDepthConvertLayer::run()
69{
70 ITensorPack pack = { { ACL_SRC, _impl->src }, { ACL_DST, _impl->dst } };
71 _impl->op->run(pack);
72}
73} // namespace arm_compute