LocalTensor Overview
LocalTensor is used to store data in the local memory of the AI Core. It supports the logical positions VECIN, VECOUT, VECCALC, A1, A2, B1, B2, CO1, and CO2.
Header Files to Be Included
1 | #include "kernel_operator.h" |
Prototype
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | template <typename T> class LocalTensor : public BaseLocalTensor<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>; __aicore__ inline LocalTensor<T>() {}; #if defined(ASCENDC_CPU_DEBUG) && ASCENDC_CPU_DEBUG == 1 ~LocalTensor(); explicit LocalTensor<T>(TBuffAddr& address); LocalTensor<T>(const LocalTensor<T>& other); LocalTensor<T> operator = (const LocalTensor<T>& other); PrimType* GetPhyAddr(const uint32_t offset) const; PrimType* GetPhyAddr() const; __inout_pipe__(S) PrimType GetValue(const uint32_t offset) const; __inout_pipe__(S) PrimType& operator()(const uint32_t offset) const; template <typename CAST_T> __aicore__ inline LocalTensor<CAST_T> ReinterpretCast() const; template <typename T1> __inout_pipe__(S) void SetValue(const uint32_t index, const T1 value) const; LocalTensor operator[](const uint32_t offset) const; template <typename T1> void SetAddrWithOffset(LocalTensor<T1> &src, uint32_t offset); inline void Print(); inline void Print(uint32_t len); int32_t ToFile(const std::string& fileName) const; #else __aicore__ inline uint64_t GetPhyAddr() const; __aicore__ inline uint64_t GetPhyAddr(const uint32_t offset) const; __aicore__ inline __inout_pipe__(S) PrimType GetValue(const uint32_t index) const; __aicore__ inline __inout_pipe__(S) __ubuf__ PrimType& operator()(const uint32_t offset) const; template <typename CAST_T> __aicore__ inline LocalTensor<CAST_T> ReinterpretCast() const; template <typename T1> __aicore__ inline __inout_pipe__(S) void SetValue(const uint32_t index, const T1 value) const; __aicore__ inline LocalTensor operator[](const uint32_t offset) const; template <typename T1> [[deprecated("NOTICE: SetAddrWithOffset has been deprecated and will be removed in the next version. " "Please do not use it!")]] __aicore__ inline void SetAddrWithOffset(LocalTensor<T1> &src, uint32_t offset); #endif __aicore__ inline LocalTensor<T>(AscendC::TPosition pos, uint32_t addr, uint32_t tieSize); __aicore__ inline int32_t GetPosition() const; __aicore__ inline void SetSize(const uint32_t size); __aicore__ inline uint32_t GetSize() const; [[deprecated("NOTICE: GetLength has been deprecated and will be removed in the next version. Please do not use " "it!")]] __aicore__ inline uint32_t GetLength() const; __aicore__ inline void SetBufferLen(uint32_t dataLen); __aicore__ inline void SetUserTag(const TTagType tag); __aicore__ inline TTagType GetUserTag() const; ... __aicore__ inline void SetShapeInfo(const ShapeInfo& shapeInfo); __aicore__ inline ShapeInfo GetShapeInfo() const; ... }; |
Template parameter
Parameter |
Description |
|---|---|
T |
The type T can be a basic data type or TensorTrait type, but the data type supported by the LocalTensor API must be supported. In particular, for the constructor function that returns a tensor object based on the specified logical position, address, or length, the type T can only be a basic data type. |
Parent topic: LocalTensor