| 1 |
/* |
| 2 |
* Copyright (c) 2018-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_GRAPH_NESUBTENSORHANDLE_H |
| 25 |
#define ARM_COMPUTE_GRAPH_NESUBTENSORHANDLE_H |
| 26 |
|
| 27 |
#include "arm_compute/graph/ITensorHandle.h" |
| 28 |
#include "arm_compute/runtime/SubTensor.h" |
| 29 |
|
| 30 |
namespace arm_compute |
| 31 |
{ |
| 32 |
namespace graph |
| 33 |
{ |
| 34 |
namespace backends |
| 35 |
{ |
| 36 |
/** CPU Sub-Tensor handle interface object **/ |
| 37 |
class NESubTensorHandle final : public ITensorHandle |
| 38 |
{ |
| 39 |
public: |
| 40 |
/** Default constructor |
| 41 |
* |
| 42 |
* @param[in] parent_handle Parent tensor handle |
| 43 |
* @param[in] shape Sub-Tensor shape |
| 44 |
* @param[in] coords Starting coordinates |
| 45 |
* @param[in] extend_parent Extends parent shape if true |
| 46 |
*/ |
| 47 |
NESubTensorHandle(ITensorHandle *parent_handle, |
| 48 |
const TensorShape &shape, |
| 49 |
const Coordinates &coords, |
| 50 |
bool extend_parent = false); |
| 51 |
/** Destructor: free the tensor's memory */ |
| 52 |
~NESubTensorHandle() = default; |
| 53 |
/** Allow instances of this class to be move constructed */ |
| 54 |
NESubTensorHandle(NESubTensorHandle &&) = default; |
| 55 |
/** Allow instances of this class to be moved */ |
| 56 |
NESubTensorHandle &operator=(NESubTensorHandle &&) = default; |
| 57 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 58 |
NESubTensorHandle(const NESubTensorHandle &) = delete; |
| 59 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 60 |
NESubTensorHandle &operator=(const NESubTensorHandle &) = delete; |
| 61 |
|
| 62 |
// Inherited overridden methods |
| 63 |
void allocate() override; |
| 64 |
void free() override; |
| 65 |
void manage(IMemoryGroup *mg) override; |
| 66 |
void map(bool blocking) override; |
| 67 |
void unmap() override; |
| 68 |
void release_if_unused() override; |
| 69 |
arm_compute::ITensor &tensor() override; |
| 70 |
const arm_compute::ITensor &tensor() const override; |
| 71 |
ITensorHandle *parent_handle() override; |
| 72 |
bool is_subtensor() const override; |
| 73 |
Target target() const override; |
| 74 |
|
| 75 |
private: |
| 76 |
arm_compute::SubTensor _sub_tensor; /**< Backend Sub-Tensor */ |
| 77 |
ITensorHandle *_parent_handle; /**< Parent handle */ |
| 78 |
}; |
| 79 |
} // namespace backends |
| 80 |
} // namespace graph |
| 81 |
} // namespace arm_compute |
| 82 |
#endif /* ARM_COMPUTE_GRAPH_NESUBTENSORHANDLE_H */ |