blob: 3ccb42361e615bd7853f923575aac04068e5a6f4 [file] [log] [blame]
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +01001/*
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +00002 * Copyright (c) 2017-2021 Arm Limited.
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +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/NEReshapeLayer.h"
25
Giuseppe Rossini6a90b692018-08-23 11:29:59 +010026#include "arm_compute/core/Validate.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010027#include "src/cpu/operators/CpuReshape.h"
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +010028
29#include <utility>
30
Georgios Pinitas33843562019-12-10 13:33:18 +000031namespace arm_compute
32{
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010033struct NEReshapeLayer::Impl
34{
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +000035 const ITensor *src{ nullptr };
36 ITensor *dst{ nullptr };
37 std::unique_ptr<cpu::CpuReshape> op{ nullptr };
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010038};
39
40NEReshapeLayer::NEReshapeLayer()
Georgios Pinitas40f51a62020-11-21 03:04:18 +000041 : _impl(std::make_unique<Impl>())
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010042{
43}
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010044NEReshapeLayer::NEReshapeLayer(NEReshapeLayer &&) = default;
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010045NEReshapeLayer &NEReshapeLayer::operator=(NEReshapeLayer &&) = default;
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +000046NEReshapeLayer::~NEReshapeLayer() = default;
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010047
Michalis Spyroubcd23522020-05-21 15:02:36 +010048void NEReshapeLayer::configure(const ITensor *input, ITensor *output)
49{
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +000050 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
51
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010052 _impl->src = input;
53 _impl->dst = output;
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +000054 _impl->op = std::make_unique<cpu::CpuReshape>();
Georgios Pinitas1fd2c802020-06-16 17:44:46 +010055 _impl->op->configure(input->info(), output->info());
Michalis Spyroubcd23522020-05-21 15:02:36 +010056}
57
58Status NEReshapeLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
59{
Giuseppe Rossini6a90b692018-08-23 11:29:59 +010060 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +000061 ARM_COMPUTE_RETURN_ON_ERROR(cpu::CpuReshape::validate(input, output));
Giuseppe Rossini6a90b692018-08-23 11:29:59 +010062
63 return Status{};
64}
Michalis Spyroubcd23522020-05-21 15:02:36 +010065
66void NEReshapeLayer::run()
67{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010068 ITensorPack pack;
69 pack.add_tensor(TensorType::ACL_SRC, _impl->src);
70 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
71 _impl->op->run(pack);
Michalis Spyroubcd23522020-05-21 15:02:36 +010072}
Matthew Bentham758b5ba2020-03-05 23:37:48 +000073} // namespace arm_compute