LogSoftMax Tiling

Function Description

To perform LogSoftMax computation in the kernel, developers need to reserve or allocate the temporary space. The LogSoftMaxTilingFunc API is used to obtain the maximum and minimum sizes of the temporary space to be reserved or allocated on the host. Developers can also call LogSoftMaxTilingFunc to obtain parameters such as reduceSize and splitSize and pass them as the tiling parameters to the kernel.

  • To ensure correct functions, the temporary space to be reserved or allocated cannot be less than the minimum temporary space.
  • Within the range between the minimum and maximum, as the temporary space increases, the API computing performance in the kernel can be optimized to some extent. To achieve better performance, reserve or allocate the space based on the actual buffer usage.

Prototype

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)

Parameters

Table 1 GetLogSoftMaxMaxTmpSize/GetLogSoftMaxMinTmpSize parameters

API

Input/Output

Function

srcShape

Input

Input shape.

typeSize

Input

Data type size of operator inputs. The unit is byte. For example, if the data type of operator inputs is half, set this parameter to 2.

isReuseSource

Input

Whether to reuse the space of the source operand input, which must be the same as that of the LogSoftMax API.

Table 2 LogSoftMaxTilingFunc parameters

API

Input/Output

Function

srcShape

Input

Input shape.

dataTypeSize

Input

Data type size of operator inputs. The unit is byte. For example, if the data type of operator inputs is half, set this parameter to 2.

localWorkSpaceSize

Input

Input temporary space.

softmaxTiling

Output

Tiling parameters passed to the kernel.

Returns

GetSoftMaxMaxTmpSize/GetSoftMaxMinTmpSize returns the maximum/minimum temporary space. LogSoftMaxTilingFunc does not return any value.

Availability

Example

1
2
3
4
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);