| 277 | |
| 278 | template<typename MemoryType> |
| 279 | class BaseTensor |
| 280 | { |
| 281 | public: |
| 282 | /// Empty (invalid) constructor. |
| 283 | BaseTensor(); |
| 284 | |
| 285 | /// Constructor from a raw memory pointer. |
| 286 | /// @param memoryArea - Region of CPU-addressable memory where tensor data will be stored. Must be valid while |
| 287 | /// workloads are on the fly. Tensor instances do not claim ownership of referenced memory regions, that is, |
| 288 | /// no attempt will be made by ArmNN to free these memory regions automatically. |
| 289 | BaseTensor(const TensorInfo& info, MemoryType memoryArea); |
| 290 | |
| 291 | /// Tensors are copyable. |
| 292 | BaseTensor(const BaseTensor& other); |
| 293 | |
| 294 | /// Tensors are copyable. |
| 295 | BaseTensor& operator=(const BaseTensor&); |
| 296 | |
| 297 | const TensorInfo& GetInfo() const { return m_Info; } |
| 298 | TensorInfo& GetInfo() { return m_Info; } |
| 299 | const TensorShape& GetShape() const { return m_Info.GetShape(); } |
| 300 | TensorShape& GetShape() { return m_Info.GetShape(); } |
| 301 | |
| 302 | DataType GetDataType() const { return m_Info.GetDataType(); } |
| 303 | unsigned int GetNumDimensions() const { return m_Info.GetNumDimensions(); } |
| 304 | unsigned int GetNumBytes() const { return m_Info.GetNumBytes(); } |
| 305 | unsigned int GetNumElements() const { return m_Info.GetNumElements(); } |
| 306 | |
| 307 | MemoryType GetMemoryArea() const { return m_MemoryArea; } |
| 308 | |
| 309 | protected: |
| 310 | /// Protected destructor to stop users from making these |
| 311 | /// (could still new one on the heap and then leak it...) |
| 312 | ~BaseTensor() {} |
| 313 | |
| 314 | MemoryType m_MemoryArea; |
| 315 | |
| 316 | private: |
| 317 | TensorInfo m_Info; |
| 318 | }; |
| 319 | |
| 320 | /// A tensor defined by a TensorInfo (shape and data type) and a mutable backing store. |
| 321 | class Tensor : public BaseTensor<void*> |