文档
注册

InitSpmBuffer

功能说明

初始化SPM Buffer。

SPM Buffer的具体介绍和完整使用样例请参考SPM Buffer

函数原型

  • 暂存到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推理系列产品(Ascend 310P处理器)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));
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词