Description: Obtains the Top- positions for each token through a series of operations.
Formulas:
For an index query corresponding to a token, given the context index key and . indicates the group size in Grouped-Query Attention (GQA). indicates the dimension of each head. indicates the context length.
Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.
- Parameters:
[object Object][object Object]
Returns
[object Object]: status code. For details, see .The first-phase API implements input parameter validation. The following error codes may be returned.
[object Object]
- The value of N in the query parameter can be less than or equal to 64, and the value of N in the key parameter can be 1.
- headdim supports 128.
- The value of block_size is a multiple of 16, and the maximum value is 1024.
- The data types of
[object Object]and[object Object]must be identical. - When the data type of
[object Object]is not[object Object], the data types of[object Object],[object Object], and[object Object]must be identical.
The following example is for reference only. For details, see .