blob: 341d93a9f6b58ac57286ca5ed734e13d84a52ceb [file] [log] [blame]
Kurtis Charnock9afc41a2019-11-11 17:24:37 +00001/*
Matthew Bentham043613f2023-05-30 16:43:14 +00002 * Copyright (c) 2019-2021, 2023 Arm Limited.
Kurtis Charnock9afc41a2019-11-11 17:24:37 +00003 *
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#ifndef ARM_COMPUTE_CLFILL_H
25#define ARM_COMPUTE_CLFILL_H
26
Matthew Bentham043613f2023-05-30 16:43:14 +000027#include "arm_compute/core/PixelValue.h"
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000028#include "arm_compute/core/Types.h"
Sheri Zhang7e20e292021-02-02 11:49:34 +000029#include "arm_compute/core/Window.h"
30#include "arm_compute/runtime/IFunction.h"
31#include <memory>
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000032
33namespace arm_compute
34{
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010035class CLCompileContext;
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000036class ICLTensor;
37
Sheri Zhang7e20e292021-02-02 11:49:34 +000038/** Basic function to run @ref opencl::kernels::ClFillKernel */
39class CLFill : public IFunction
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000040{
41public:
Sheri Zhang7e20e292021-02-02 11:49:34 +000042 /** Constructor */
43 CLFill();
44 /** Destructor */
45 ~CLFill();
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 CLFill(const CLFill &) = delete;
48 /** Default move constructor */
49 CLFill(CLFill &&);
50 /** Prevent instances of this class from being copied (As this class contains pointers) */
51 CLFill &operator=(const CLFill &) = delete;
52 /** Default move assignment operator */
53 CLFill &operator=(CLFill &&);
54 /** Initialize the kernel's tensor and filling value
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000055 *
Sheri Zhanga47dcc22021-04-22 14:41:12 +010056 * Valid data layouts:
57 * - All
58 *
59 * Valid data type configurations:
60 * |src |dst |
61 * |:--------------|:--------------|
62 * |All |All |
63 *
Sheri Zhang7e20e292021-02-02 11:49:34 +000064 * @param[in,out] tensor Input tensor to fill. Supported data types: All.
65 * @param[in] constant_value The value used to fill the planes of the tensor
66 * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000067 */
Sheri Zhang7e20e292021-02-02 11:49:34 +000068 void configure(ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
69 /** Initialise the kernel's tensor and filling value
Manuel Bottini2b84be52020-04-08 10:15:51 +010070 *
71 * @param[in] compile_context The compile context to be used.
Sheri Zhang7e20e292021-02-02 11:49:34 +000072 * @param[in,out] tensor Input tensor to fill. Supported data types: All.
73 * @param[in] constant_value The value used to fill the planes of the tensor
74 * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
Manuel Bottini2b84be52020-04-08 10:15:51 +010075 */
Sheri Zhang7e20e292021-02-02 11:49:34 +000076 void configure(const CLCompileContext &compile_context, ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
77 /** Static function to check if given info will lead to a valid configuration of @ref CLFill
78 *
79 * @param[in] tensor Source tensor info. Data types supported: All.
80 * @param[in] constant_value The value used to fill the planes of the tensor
81 * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
82 *
83 * @return a status
84 */
85 static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
86
87 // Inherited methods overridden:
88 void run() override;
89
90private:
91 struct Impl;
92 std::unique_ptr<Impl> _impl;
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000093};
94} // namespace arm_compute
95#endif /*ARM_COMPUTE_CLFILL_H */