Accessor implementation for @ref Tensor objects. */
| 34 | { |
| 35 | /** Accessor implementation for @ref Tensor objects. */ |
| 36 | class Accessor : public IAccessor |
| 37 | { |
| 38 | public: |
| 39 | /** Create an accessor for the given @p tensor. |
| 40 | * |
| 41 | * @param[in, out] tensor To be accessed tensor. |
| 42 | */ |
| 43 | Accessor(ITensor &tensor); |
| 44 | |
| 45 | /** Prevent instances of this class from being copy constructed */ |
| 46 | Accessor(const Accessor &) = delete; |
| 47 | /** Prevent instances of this class from being copied */ |
| 48 | Accessor &operator=(const Accessor &) = delete; |
| 49 | /** Allow instances of this class to be move constructed */ |
| 50 | Accessor(Accessor &&) = default; |
| 51 | |
| 52 | /** Get the tensor data. |
| 53 | * |
| 54 | * @return a constant pointer to the tensor data. |
| 55 | */ |
| 56 | const void *data() const; |
| 57 | /** Get the tensor data. |
| 58 | * |
| 59 | * @return a pointer to the tensor data. |
| 60 | */ |
| 61 | void *data(); |
| 62 | |
| 63 | TensorShape shape() const override; |
| 64 | size_t element_size() const override; |
| 65 | size_t size() const override; |
| 66 | Format format() const override; |
| 67 | DataLayout data_layout() const override; |
| 68 | DataType data_type() const override; |
| 69 | int num_channels() const override; |
| 70 | int num_elements() const override; |
| 71 | PaddingSize padding() const override; |
| 72 | QuantizationInfo quantization_info() const override; |
| 73 | const void *operator()(const Coordinates &coord) const override; |
| 74 | void *operator()(const Coordinates &coord) override; |
| 75 | |
| 76 | private: |
| 77 | ITensor &_tensor; |
| 78 | }; |
| 79 | |
| 80 | inline Accessor::Accessor(ITensor &tensor) : _tensor{tensor} |
| 81 | { |
no outgoing calls