Compute Library
 22.02
CLFill.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2021 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 #ifndef ARM_COMPUTE_CLFILL_H
25 #define ARM_COMPUTE_CLFILL_H
26 
27 #include "arm_compute/core/Types.h"
30 #include <memory>
31 
32 namespace arm_compute
33 {
34 class CLCompileContext;
35 class ICLTensor;
36 
37 /** Basic function to run @ref opencl::kernels::ClFillKernel */
38 class CLFill : public IFunction
39 {
40 public:
41  /** 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
54  *
55  * Valid data layouts:
56  * - All
57  *
58  * Valid data type configurations:
59  * |src |dst |
60  * |:--------------|:--------------|
61  * |All |All |
62  *
63  * @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.
66  */
67  void configure(ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
68  /** Initialise the kernel's tensor and filling value
69  *
70  * @param[in] compile_context The compile context to be used.
71  * @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.
74  */
75  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 
89 private:
90  struct Impl;
91  std::unique_ptr<Impl> _impl;
92 };
93 } // namespace arm_compute
94 #endif /*ARM_COMPUTE_CLFILL_H */
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
Base class for all functions.
Definition: IFunction.h:30
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Copyright (c) 2017-2021 Arm Limited.
void run() override
Run the kernels contained in the function.
Definition: CLFill.cpp:72
CLFill & operator=(const CLFill &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
void configure(ICLTensor *tensor, const PixelValue &constant_value, Window *window=nullptr)
Initialize the kernel&#39;s tensor and filling value.
Definition: CLFill.cpp:52
CLCompileContext class.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window=nullptr)
Static function to check if given info will lead to a valid configuration of CLFill.
Definition: CLFill.cpp:67
CLFill()
Constructor.
Definition: CLFill.cpp:44
Basic function to run opencl::kernels::ClFillKernel.
Definition: CLFill.h:38
Describe a multidimensional execution window.
Definition: Window.h:39
~CLFill()
Destructor.