InitBuffer

Applicability

Product

Supported/Unsupported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product 's AI Core

Atlas inference product 's Vector Core

x

Atlas training products

Function Usage

Calls TBufPool::InitBuffer to allocate buffer for the TQue/TBuf.

Prototype

1
2
template <class T> __aicore__ inline bool InitBuffer(T& que, uint8_t num, uint32_t len)
template <TPosition pos> __aicore__ inline bool InitBuffer(TBuf<pos>& buf, uint32_t len)

Parameters

Table 1 Parameters in the template

Parameter

Description

T

Type of the que parameter.

pos

Logical location of Buffer. The value can be VECIN, VECOUT, VECCALC, A1, B1, or C1. For details about TPosition, see TPosition.

Table 2 Parameters in InitBuffer(T& que, uint8_t num, uint32_t len) prototype definition

Parameter

Input/Output

Meaning

que

Input

TQue object that requires memory allocation

num

Input

Number of allocated buffers

len

Input

Size of each buffer, in bytes. If the size is not 32-byte aligned, it is automatically padded up to 32-byte aligned.

Table 3 Parameters in InitBuffer(TBuf<pos>& buf, uint32_t len) prototype definition

Parameter

Input/Output

Meaning

buf

Input

TBuf object that requires memory allocation

len

Input

Size of the memory allocated to the TBuf, in bytes. If the size is not 32-byte aligned, it is automatically padded up to 32-byte aligned.

Restrictions

When declaring TBufPool, you can use bufIDSize to specify the maximum number of buffers that can be allocated. The default upper limit is 4, and the maximum value is 16. The physical memory of the TQue or TBuf must be the same as that of the TBufPool.

Returns

None

Example

See InitBufPool.