blob: 78c7ea202a9c775ddd7d41cf103754b984489cce [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Teresa Charlind1dc09c2021-03-04 15:24:45 +00002 * Copyright (c) 2017-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 */
24#include "arm_compute/runtime/NEON/functions/NETranspose.h"
25
Teresa Charlind1dc09c2021-03-04 15:24:45 +000026#include "arm_compute/core/Validate.h"
ramelg01cbbb0382021-09-17 17:36:57 +010027#include "src/common/utils/Log.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010028#include "src/cpu/operators/CpuTranspose.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029
Georgios Pinitas33843562019-12-10 13:33:18 +000030namespace arm_compute
31{
Teresa Charlind1dc09c2021-03-04 15:24:45 +000032struct NETranspose::Impl
33{
34 const ITensor *src{ nullptr };
35 ITensor *dst{ nullptr };
36 std::unique_ptr<cpu::CpuTranspose> op{ nullptr };
37};
38
39NETranspose::NETranspose()
40 : _impl(std::make_unique<Impl>())
41{
42}
43
44NETranspose::~NETranspose() = default;
45
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046void NETranspose::configure(const ITensor *input, ITensor *output)
47{
Teresa Charlind1dc09c2021-03-04 15:24:45 +000048 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
ramelg01cbbb0382021-09-17 17:36:57 +010049 ARM_COMPUTE_LOG_PARAMS(input, output);
Teresa Charlind1dc09c2021-03-04 15:24:45 +000050
51 _impl->src = input;
52 _impl->dst = output;
53 _impl->op = std::make_unique<cpu::CpuTranspose>();
54 _impl->op->configure(input->info(), output->info());
Anthony Barbier6ff3b192017-09-04 18:44:23 +010055}
Gian Marco7c435f22017-12-05 16:17:23 +000056
Georgios Pinitas631c41a2017-12-06 11:53:03 +000057Status NETranspose::validate(const ITensorInfo *input, const ITensorInfo *output)
Gian Marco7c435f22017-12-05 16:17:23 +000058{
Teresa Charlind1dc09c2021-03-04 15:24:45 +000059 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
60 ARM_COMPUTE_RETURN_ON_ERROR(cpu::CpuTranspose::validate(input, output));
61 return Status{};
Georgios Pinitas33843562019-12-10 13:33:18 +000062}
Teresa Charlind1dc09c2021-03-04 15:24:45 +000063
64void NETranspose::run()
65{
66 ITensorPack pack;
67 pack.add_tensor(TensorType::ACL_SRC, _impl->src);
68 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
69 _impl->op->run(pack);
70}
71
Matthew Bentham758b5ba2020-03-05 23:37:48 +000072} // namespace arm_compute