InitSpmBuffer
函数原型
- 暂存到workspace初始化,需要指定GM地址为SPM Buffer:
      template <typename T> __aicore__ inline void InitSpmBuffer(const GlobalTensor<T>& workspace, const int bufferSize); 
- 暂存到L1 Buffer初始化,不需要指定地址,会默认暂存到L1 Buffer,只需要传入需要的SPM Buffer大小:
      __aicore__ inline void InitSpmBuffer(const int32_t bufferSize); Atlas A2训练系列产品/Atlas 800I A2推理产品,不支持暂存到L1 Buffer初始化接口。 
参数说明
| 参数名称 | 输入/输出 | 含义 | 
|---|---|---|
| wokspace | 输入 | workspace地址。 | 
| bufferSize | 输入 | SPM Buffer的大小,单位是字节。 | 
支持的型号
Atlas 训练系列产品
Atlas推理系列产品AI Core
Atlas A2训练系列产品/Atlas 800I A2推理产品
注意事项
无
返回值
无
调用示例
- 暂存到workspace初始化
      TPipe pipe; int len = 1024; // 设置spm buffer为1024个类型为T的数据 workspace_gm.SetGlobalBuffer((__gm__ T *)usrWorkspace,len); // 此处的usrWorkspace为用户自定义的workspace auto gm = workspace_gm[GetBlockIdx() * len]; pipe.InitSpmBuffer(gm, len * sizeof(T)); 
- 暂存到L1 Buffer初始化
      TPipe pipe; int len = 1024; // 设置spm buffer为1024个类型为T的数据 pipe.InitSpmBuffer(len * sizeof(T)); 
     父主题: SPM Buffer