blob: e017e8c21dff280e6696aa8fe9c59f3e322cb089 [file] [log] [blame]
Adnan AlSinan171fc3d2022-03-15 18:46:42 +00001/*
2 * Copyright (c) 2022 Arm Limited.
3 *
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/NEPooling3dLayer.h"
25
26#include "arm_compute/core/TensorInfo.h"
27#include "arm_compute/core/Validate.h"
28#include "arm_compute/runtime/Tensor.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010029
Adnan AlSinan171fc3d2022-03-15 18:46:42 +000030#include "src/core/helpers/MemoryHelpers.h"
31#include "src/cpu/operators/CpuPool3d.h"
32
33namespace arm_compute
34{
35struct NEPooling3dLayer::Impl
36{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010037 const ITensor *src{nullptr};
38 ITensor *dst{nullptr};
39 std::unique_ptr<cpu::CpuPool3d> op{nullptr};
Adnan AlSinan171fc3d2022-03-15 18:46:42 +000040 MemoryGroup memory_group{};
41 ITensorPack run_pack{};
42 WorkspaceData<Tensor> workspace_tensors{};
43};
44
45NEPooling3dLayer::~NEPooling3dLayer() = default;
46
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010047NEPooling3dLayer::NEPooling3dLayer(std::shared_ptr<IMemoryManager> memory_manager) : _impl(std::make_unique<Impl>())
Adnan AlSinan171fc3d2022-03-15 18:46:42 +000048{
49 _impl->memory_group = MemoryGroup(std::move(memory_manager));
50}
51
52void NEPooling3dLayer::configure(const ITensor *input, ITensor *output, const Pooling3dLayerInfo &pool_info)
53{
54 _impl->src = input;
55 _impl->dst = output;
56 _impl->op = std::make_unique<cpu::CpuPool3d>();
57 _impl->op->configure(input->info(), output->info(), pool_info);
58
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010059 _impl->run_pack = {{TensorType::ACL_SRC, _impl->src}, {TensorType::ACL_DST_0, _impl->dst}};
Adnan AlSinan171fc3d2022-03-15 18:46:42 +000060 _impl->workspace_tensors = manage_workspace<Tensor>(_impl->op->workspace(), _impl->memory_group, _impl->run_pack);
61}
62
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010063Status
64NEPooling3dLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const Pooling3dLayerInfo &pool_info)
Adnan AlSinan171fc3d2022-03-15 18:46:42 +000065{
66 return cpu::CpuPool3d::validate(input, output, pool_info);
67}
68
69void NEPooling3dLayer::run()
70{
71 MemoryGroupResourceScope scope_mg(_impl->memory_group);
72 ARM_COMPUTE_ERROR_ON_NULLPTR(_impl->src, _impl->dst);
73 _impl->op->run(_impl->run_pack);
74}
75
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010076} // namespace arm_compute