输入输出

topkToppSamplingType = SINGLE_TOPK_SAMPLING(非batch级随机种子、topk取样)

参数

维度

数据类型

格式

描述

probs

[batch, voc_size]

float16/bf16

ND

输入,词表概率。

topp

[batch, 1]

float16/bf16

ND

输入topp,topp截取的概率,batch的值需与probs的一致。

sampled_indices

[batch, 1]

int32

ND

输出,取样的idx。

sampled_probs

[batch, 1]

float16/bf16

ND

输出,取样的值。

topkToppSamplingType = BATCH_TOPK_MULTINOMIAL_SAMPLING(batch级随机种子,topk的multinomial取样)

参数

维度

数据类型

格式

描述

probs

[batch, voc_size]

float16/bf16

ND

输入,词表概率。

topk

[batch, 1]

int32

ND

输入top-k,topk截取的位置,batch的值需与probs的一致。

topp

[batch, 1]

float16/bf16

ND

输入,topp截取的概率,batch的值需与probs的一致。

sampled_indices

[batch, 1]

int32

ND

输出,取样的idx。

sampled_probs

[batch, 1]

float16/bf16

ND

输出,取样的值。

topkToppSamplingType = BATCH_TOPK_EXPONENTIAL_SAMPLING(batch级随机种子,topk的Exponential取样)

参数

维度

数据类型

格式

描述

probs

[batch, voc_size]

float16/bf16

ND

输入,词表概率。

topk

[batch, 1]

int32

ND

输入top-k,topk截取的位置,batch的值需与probs的一致。

topp

[batch, 1]

float16/bf16

ND

输入,topp截取的概率,batch的值需与probs的一致。

exp

[batch, voc_size]

float16/bf16

ND

输入,所除的指数分布,维度需与probs的一致。

sampled_indices

[batch, 1]

int32

ND

输出,取样的idx。

sampled_probs

[batch, 1]

float16/bf16

ND

输出,取样的值。

topkToppSamplingType = BATCH_TOPK_MULTINOMIAL_LOGPROBS_SAMPLING(batch级随机种子,topk的multinomial取样)

参数

维度

数据类型

格式

描述

probs

[batch, voc_size]

float16/bf16

ND

输入,词表概率。

topk

[batch, 1]

int32

ND

输入top-k,top-k截取的位置,batch的值需与probs的一致。

topp

[batch, 1]

float16/bf16

ND

输入top-p,top-p截取的概率,batch的值需与probs的一致。

rand

[batch, 1]

float

ND

输入,值域为[0, 1],参考rand() / RAND_MAX。

sampled_indices

[batch, 1]

int32

ND

输出,取样的序号。

sampled_probs

[batch, 1]

float16/bf16

ND

输出,取样的值。

sampled_logprobs

[batch, logProbsSize]

float

ND

输出,topkToppSamplingType = BATCH_TOPK_MULTINOMIAL_LOGPROBS_SAMPLING时有效。值为对应概率值的对数。

topkToppSamplingType = BATCH_TOPK_EXPONENTIAL_LOGPROBS_SAMPLING(batch级随机种子,topk的Exponential取样)

参数

维度

数据类型

格式

描述

probs

[batch, voc_size]

float16/bf16

ND

输入,词表概率。

topk

[batch, 1]

int32

ND

输入top-k,top-k截取的位置,batch的值需与probs的一致。

topp

[batch, 1]

float16/bf16

ND

输入top-p,top-p截取的概率,batch的值需与probs的一致。

exp

[batch, voc_size]

float16/bf16

ND

输入,所除的指数分布,维度需与probs的一致。

sampled_indices

[batch, 1]

int32

ND

输出,取样的序号。

sampled_probs

[batch, 1]

float16/bf16

ND

输出,取样的值。

sampled_logprobs

[batch, logProbsSize]

float

ND

输出,topkToppSamplingType = BATCH_TOPK_EXPONENTIAL_LOGPROBS_SAMPLING时有效。值为对应概率值的对数。