kernel侧LogSoftMax接口的计算需要开发者预留/申请临时空间,以下接口用于在host侧获取预留/申请的最大最小临时空间大小,开发者基于此范围选择合适的空间大小,并调用LogSoftMaxTilingFunc函数获取reduceSize,splitSize等参数,作为Tiling参数传递到kernel侧使用。
1 | uint32_t GetLogSoftMaxMaxTmpSize(const ge::Shape srcShape, const uint32_t dataTypeSize, const bool isReuseSource) |
1 | uint32_t GetLogSoftMaxMinTmpSize(const ge::Shape srcShape, const uint32_t dataTypeSize, const bool isReuseSource) |
1 | void LogSoftMaxTilingFunc(const ge::Shape srcShape, const uint32_t dataTypeSize, const uint32_t localWorkSpaceSize, optiling::LogSoftMaxTiling& softmaxTiling) |
接口 |
输入/输出 |
功能 |
---|---|---|
srcShape |
输入 |
输入的shape信息。 |
typeSize |
输入 |
算子输入的数据类型大小,单位为字节。比如算子输入的数据类型为half,此处应传入2。 |
isReuseSource |
输入 |
是否复用源操作数输入的空间,与LogSoftMax接口一致。 |
接口 |
输入/输出 |
功能 |
---|---|---|
srcShape |
输入 |
输入的shape信息。 |
dataTypeSize |
输入 |
算子输入的数据类型大小,单位为字节。比如算子输入的数据类型为half,此处应传入2。 |
localWorkSpaceSize |
输入 |
输入的临时空间大小。 |
softmaxTiling |
输出 |
传递到kernel侧使用的Tiling参数。 |
GetSoftMaxMaxTmpSize/GetSoftMaxMinTmpSize接口返回值为最大/最小临时空间,LogSoftMaxTilingFunc接口无返回值。
Atlas A2训练系列产品/Atlas 800I A2推理产品
Atlas推理系列产品AI Core
std::vector<int64_t> srcDims = {outter, inner}; ge::Shape shape(srcDims); const uint32_t tmpsize = AscendC::GetLogSoftMaxMaxTmpSize(shape, dtypesize, false); AscendC::LogSoftMaxTilingFunc(shape, dtypesize, tmpsize, tiling.logSoftmaxTilingData);