FastSoftMaxOperation
功能
将unpad处理后的Q矩阵和K矩阵相乘的结果做Softmax处理。
约束
qSeqLen数组长度不超过32,且要求各元素大于0。
定义
struct FastSoftMaxParam {
int32_t headNum = 0;
std::vector<int32_t> qSeqLen;
bool operator == (const RopeParam &other) const
{
return this->rotaryCoeff == other.rotaryCoeff && this->cosFormat == other.cosFormat;
}
};
成员
成员名称 |
描述 |
|---|---|
headnum |
Attention的head数量。 |
qSeqLen |
每个batch的实际输入长度。元素个数为batchSize,最大不超过32。 |
输入
参数 |
维度 |
数据类型 |
格式 |
描述 |
|---|---|---|---|---|
input |
[nSquareTokens] |
float16 |
ND |
输入向量,随机tensor。
|
输出
参数 |
维度 |
数据类型 |
格式 |
描述 |
|---|---|---|---|---|
output |
[nSquareTokens] |
float16 |
ND |
结果向量,范围在[0, 1]的概率tensor。 |
