blob: a01e0c3188ebc67adceffba931e879b9d2744381 [file] [log] [blame]
Kurtis Charnock9afc41a2019-11-11 17:24:37 +00001/*
Sheri Zhang7e20e292021-02-02 11:49:34 +00002 * Copyright (c) 2019-2021 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
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000027#include "arm_compute/core/Types.h"
Sheri Zhang7e20e292021-02-02 11:49:34 +000028#include "arm_compute/core/Window.h"
29#include "arm_compute/runtime/IFunction.h"
30#include <memory>
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000031
32namespace arm_compute
33{
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010034class CLCompileContext;
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000035class ICLTensor;
36
Sheri Zhang7e20e292021-02-02 11:49:34 +000037/** Basic function to run @ref opencl::kernels::ClFillKernel */
38class CLFill : public IFunction
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000039{
40public:
Sheri Zhang7e20e292021-02-02 11:49:34 +000041 /** Constructor */
42 CLFill();
43 /** Destructor */
44 ~CLFill();
45 /** Prevent instances of this class from being copied (As this class contains pointers) */
46 CLFill(const CLFill &) = delete;
47 /** Default move constructor */
48 CLFill(CLFill &&);
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 CLFill &operator=(const CLFill &) = delete;
51 /** Default move assignment operator */
52 CLFill &operator=(CLFill &&);
53 /** Initialize the kernel's tensor and filling value
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000054 *
Sheri Zhanga47dcc22021-04-22 14:41:12 +010055 * Valid data layouts:
56 * - All
57 *
58 * Valid data type configurations:
59 * |src |dst |
60 * |:--------------|:--------------|
61 * |All |All |
62 *
Sheri Zhang7e20e292021-02-02 11:49:34 +000063 * @param[in,out] tensor Input tensor to fill. Supported data types: All.
64 * @param[in] constant_value The value used to fill the planes of the tensor
65 * @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 +000066 */
Sheri Zhang7e20e292021-02-02 11:49:34 +000067 void configure(ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
68 /** Initialise the kernel's tensor and filling value
Manuel Bottini2b84be52020-04-08 10:15:51 +010069 *
70 * @param[in] compile_context The compile context to be used.
Sheri Zhang7e20e292021-02-02 11:49:34 +000071 * @param[in,out] tensor Input tensor to fill. Supported data types: All.
72 * @param[in] constant_value The value used to fill the planes of the tensor
73 * @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 +010074 */
Sheri Zhang7e20e292021-02-02 11:49:34 +000075 void configure(const CLCompileContext &compile_context, ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
76 /** Static function to check if given info will lead to a valid configuration of @ref CLFill
77 *
78 * @param[in] tensor Source tensor info. Data types supported: All.
79 * @param[in] constant_value The value used to fill the planes of the tensor
80 * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
81 *
82 * @return a status
83 */
84 static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
85
86 // Inherited methods overridden:
87 void run() override;
88
89private:
90 struct Impl;
91 std::unique_ptr<Impl> _impl;
Kurtis Charnock9afc41a2019-11-11 17:24:37 +000092};
93} // namespace arm_compute
94#endif /*ARM_COMPUTE_CLFILL_H */