Compute Library
 21.05
CLSubTensorHandle.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019 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_GRAPH_CLSUBTENSORHANDLE_H
25 #define ARM_COMPUTE_GRAPH_CLSUBTENSORHANDLE_H
26 
28 
30 
31 namespace arm_compute
32 {
33 namespace graph
34 {
35 namespace backends
36 {
37 /** OpenCL Sub-Tensor handle interface object **/
38 class CLSubTensorHandle final : public ITensorHandle
39 {
40 public:
41  /** Default constructor
42  *
43  * @param[in] parent_handle Parent tensor handle
44  * @param[in] shape Sub-Tensor shape
45  * @param[in] coords Starting coordinates
46  * @param[in] extend_parent Extends parent shape if true
47  */
48  CLSubTensorHandle(ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords, bool extend_parent = false);
49  /** Destructor: free the tensor's memory */
50  ~CLSubTensorHandle() = default;
51  /** Allow instances of this class to be move constructed */
53  /** Allow instances of this class to be moved */
55  /** Prevent instances of this class from being copied (As this class contains pointers) */
56  CLSubTensorHandle(const CLSubTensorHandle &) = delete;
57  /** Prevent instances of this class from being copied (As this class contains pointers) */
59 
60  // Inherited overridden methods
61  void allocate() override;
62  void free() override;
63  void manage(IMemoryGroup *mg) override;
64  void map(bool blocking) override;
65  void unmap() override;
66  void release_if_unused() override;
67  arm_compute::ITensor &tensor() override;
68  const arm_compute::ITensor &tensor() const override;
69  ITensorHandle *parent_handle() override;
70  bool is_subtensor() const override;
71  Target target() const override;
72 
73 private:
74  arm_compute::CLSubTensor _sub_tensor; /**< Backend Sub-Tensor */
75  ITensorHandle *_parent_handle; /**< Parent handle */
76 };
77 } // namespace backends
78 } // namespace graph
79 } // namespace arm_compute
80 #endif /* ARM_COMPUTE_GRAPH_CLSUBTENSORHANDLE_H */
Memory group interface.
Definition: IMemoryGroup.h:37
arm_compute::ITensor & tensor() override
Backend tensor object accessor.
void map(bool blocking) override
Maps backend tensor object.
Shape of a tensor.
Definition: TensorShape.h:39
CLSubTensorHandle(ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords, bool extend_parent=false)
Default constructor.
void free() override
Allocates backend memory for the handle.
void manage(IMemoryGroup *mg) override
Set backend tensor to be managed by a memory group.
void allocate() override
Allocates backend memory for the handle.
void release_if_unused() override
Releases backend tensor if is marked as unused.
CLSubTensorHandle & operator=(CLSubTensorHandle &&)=default
Allow instances of this class to be moved.
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
OpenCL Sub-Tensor handle interface object.
Coordinates of an item.
Definition: Coordinates.h:37
Tensor handle interface object.
Definition: ITensorHandle.h:38
void unmap() override
Un-maps a backend tensor object.
bool is_subtensor() const override
Checks if a backing tensor is a sub-tensor object or not.
Basic implementation of the OpenCL sub-tensor interface.
Definition: CLSubTensor.h:37
Target target() const override
Returns target type.
ITensorHandle * parent_handle() override
Return the parent tensor handle if is a subtensor else this.
~CLSubTensorHandle()=default
Destructor: free the tensor's memory.