CANN/asc-devkit SetGlobalBuffer函数 SetGlobalBuffer产品支持情况产品是否支持Ascend 950PR/Ascend 950DT√Atlas A3 训练系列产品 / Atlas A3 推理系列产品√Atlas A2 训练系列产品 / Atlas A2 推理系列产品√Atlas 200I/500 A2 推理产品√Atlas 推理系列产品 AI Core√Atlas 推理系列产品 Vector Core√Atlas 训练系列产品√功能说明传入全局数据地址初始化GlobalTensor。函数原型传入全局数据的指针并设置存储大小通过元素个数表达。__aicore__ inline void SetGlobalBuffer(__gm__ PrimType* buffer, uint64_t bufferSize)仅传入全局数据的指针此时通过GetSize获取到的元素个数为0。__aicore__ inline void SetGlobalBuffer(__gm__ PrimType* buffer)参数说明表 1参数说明参数名输入/输出描述buffer输入Host侧传入的全局数据指针。PrimType类型。PrimType定义如下// PrimT用于从T中提取基础数据类型T传入基础数据类型直接返回数据类型T传入为TensorTrait类型时萃取TensorTrait中的LiteType基础数据类型 using PrimType PrimTT;bufferSize输入GlobalTensor所包含的类型为PrimType的数据个数需自行保证不会超出实际数据的长度。如指向的外部存储有连续256个int32_t则其bufferSize为256。返回值说明无。约束说明无。调用示例uint64_t dataSize 256; //设置input_global的大小为256 AscendC::GlobalTensorint32_t inputGlobal; // 类型为int32_t inputGlobal.SetGlobalBuffer(reinterpret_cast__gm__ int32_t *(src_gm), dataSize); // 设置源操作数在Global Memory上的起始地址为src_gm所占外部存储的大小为256个int32_t AscendC::LocalTensorint32_t inputLocal inQueueX.AllocTensorint32_t(); AscendC::DataCopy(inputLocal, inputGlobal, dataSize); // 将Global Memory上的inputGlobal拷贝到Local Memory的inputLocal上创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考