GlobalTensor Overview
Stores the global data of the global memory (external storage).
The public member functions of GlobalTensor are as follows. Type T supports the basic data types and the TensorTrait type, but must comply with the data types supported by the instructions that use the GlobalTensor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | template <typename T> class GlobalTensor : public BaseGlobalTensor<T> { public: // PrimT is used to extract the basic data type LiteType from TensorTrait when T is of the TensorTrait type. using PrimType = PrimT<T>; // Constructor. __aicore__ inline GlobalTensor<T>() {} // Initialize GlobalTensor. __aicore__ inline void SetGlobalBuffer(__gm__ PrimType* buffer, uint64_t bufferSize); __aicore__ inline void SetGlobalBuffer(__gm__ PrimType* buffer); // Obtain the address of the global data. __aicore__ inline const __gm__ PrimType* GetPhyAddr() const; __aicore__ inline __gm__ PrimType* GetPhyAddr(const uint64_t offset) const; // Obtain the value of the corresponding offset position of GlobalTensor. __aicore__ inline __inout_pipe__(S) PrimType GetValue(const uint64_t offset) const; // Obtain the reference of an element numbered as index. __aicore__ inline __inout_pipe__(S) __gm__ PrimType& operator()(const uint64_t offset) const; // Set the value of the corresponding offset position of GlobalTensor. __aicore__ inline void SetValue(const uint64_t offset, PrimType value); // Obtain the number of elements in GlobalTensor. __aicore__ inline uint64_t GetSize() const; // Return GlobalTensor with the specified offset. __aicore__ inline GlobalTensor operator[](const uint64_t offset) const; // Set the shape information of GlobalTensor. __aicore__ inline void SetShapeInfo(const ShapeInfo& shapeInfo); // Obtain the shape information of GlobalTensor. __aicore__ inline ShapeInfo GetShapeInfo() const; // Set the mode for writing GlobalTensor to the L2 cache. template<CacheRwMode rwMode = CacheRwMode::RW> __aicore__ inline void SetL2CacheHint(CacheMode mode); ... }; |
Parent topic: GlobalTensor