blob: a3798daf61bd3047c988516e382b1c96bbab6d8e [file] [log] [blame]
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +01001/*
SiCong Li4ceb4532023-03-13 15:02:23 +00002 * Copyright (c) 2018-2021, 2023 Arm Limited.
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +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
25#include "arm_compute/runtime/CL/functions/CLBatchToSpaceLayer.h"
26
27#include "arm_compute/core/Error.h"
28#include "arm_compute/core/TensorInfo.h"
29#include "arm_compute/core/Types.h"
30#include "arm_compute/core/Validate.h"
31#include "arm_compute/runtime/CL/CLScheduler.h"
32
ramelg016d891572021-09-29 10:05:09 +010033#include "src/common/utils/Log.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010034#include "src/core/CL/kernels/CLBatchToSpaceLayerKernel.h"
ramelg016d891572021-09-29 10:05:09 +010035
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010036namespace arm_compute
37{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010038CLBatchToSpaceLayer::CLBatchToSpaceLayer() : _batch_to_space_kernel(std::make_unique<CLBatchToSpaceLayerKernel>())
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010039{
40}
41
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010042CLBatchToSpaceLayer::~CLBatchToSpaceLayer() = default;
43
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010044void CLBatchToSpaceLayer::configure(const ICLTensor *input, const ICLTensor *block_shape, ICLTensor *output)
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010045{
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010046 ARM_COMPUTE_LOG_PARAMS(input, block_shape, output);
47 _batch_to_space_kernel->configure(CLKernelLibrary::get().get_compile_context(), input, block_shape, output);
Manuel Bottini2b84be52020-04-08 10:15:51 +010048}
49
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010050void CLBatchToSpaceLayer::configure(const CLCompileContext &compile_context,
51 const ICLTensor *input,
52 const ICLTensor *block_shape,
53 ICLTensor *output)
Manuel Bottini2b84be52020-04-08 10:15:51 +010054{
ramelg016d891572021-09-29 10:05:09 +010055 ARM_COMPUTE_LOG_PARAMS(input, block_shape, output);
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010056 _batch_to_space_kernel->configure(compile_context, input, block_shape, output);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010057}
58
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010059void CLBatchToSpaceLayer::configure(
60 const ICLTensor *input, int32_t block_shape_x, int32_t block_shape_y, ICLTensor *output, const CropInfo &crop_info)
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010061{
SiCong Li4ceb4532023-03-13 15:02:23 +000062 configure(CLKernelLibrary::get().get_compile_context(), input, block_shape_x, block_shape_y, output, crop_info);
Manuel Bottini2b84be52020-04-08 10:15:51 +010063}
64
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010065void CLBatchToSpaceLayer::configure(const CLCompileContext &compile_context,
66 const ICLTensor *input,
67 int32_t block_shape_x,
68 int32_t block_shape_y,
69 ICLTensor *output,
70 const CropInfo &crop_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010071{
ramelg016d891572021-09-29 10:05:09 +010072 ARM_COMPUTE_LOG_PARAMS(input, block_shape_x, block_shape_y, output);
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010073 _batch_to_space_kernel->configure(compile_context, input, block_shape_x, block_shape_y, output, crop_info);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010074}
75
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010076Status
77CLBatchToSpaceLayer::validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *output)
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010078{
79 return CLBatchToSpaceLayerKernel::validate(input, block_shape, output);
80}
81
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010082Status CLBatchToSpaceLayer::validate(const ITensorInfo *input,
83 int32_t block_shape_x,
84 int32_t block_shape_y,
85 const ITensorInfo *output,
86 const CropInfo &crop_info)
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010087{
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010088 return CLBatchToSpaceLayerKernel::validate(input, block_shape_x, block_shape_y, output, crop_info);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010089}
90
91void CLBatchToSpaceLayer::run()
92{
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010093 CLScheduler::get().enqueue(*_batch_to_space_kernel, true);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010094}
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010095} // namespace arm_compute