SetGlobalBuffer
Product Support
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function
Passes the address of the global data to initialize the GlobalTensor.
Prototype
- Passes the global data pointer and sets the storage size (expressed by the number of elements).
1__aicore__ inline void SetGlobalBuffer(__gm__ PrimType* buffer, uint64_t bufferSize)
- Passes only the global data pointer. In this case, the number of elements obtained through GetSize is 0.
1__aicore__ inline void SetGlobalBuffer(__gm__ PrimType* buffer)
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
buffer |
Input |
Global data pointer passed from the host, which is of the PrimType type. PrimType is defined as follows:
|
||
bufferSize |
Input |
Number of data records of the PrimType type contained in the GlobalTensor. Ensure that the value does not exceed the actual data length. For example, if the pointed external storage contains 256 consecutive int32_t data elements, bufferSize is 256. |
Returns
None
Restrictions
None
Example
1 2 3 4 5 6 7 8 9 10 11 | void Init(__gm__ uint8_t *src_gm, __gm__ uint8_t *dst_gm) { uint64_t dataSize = 256; // Set the size of input_global to 256. AscendC::GlobalTensor<int32_t> inputGlobal; // The type is int32_t. inputGlobal.SetGlobalBuffer(reinterpret_cast<__gm__ int32_t *>(src_gm), dataSize); // Set the start address of the source operand in the global memory to src_gm and the size of the external storage occupied by the source operand to 256 int32_t data elements. AscendC::LocalTensor<int32_t> inputLocal = inQueueX.AllocTensor<int32_t>(); AscendC::DataCopy(inputLocal, inputGlobal, dataSize); // Copy inputGlobal from the global memory to inputLocal of the local memory. ... } |
Parent topic: GlobalTensor