《012-仇径.pdf》由会员分享,可在线阅读,更多相关《012-仇径.pdf(23页珍藏版)》请在三个皮匠报告上搜索。
1、面向 AI 应用的玄铁扩展指令仇径阿里巴巴达摩院Contents目录SFU 扩展指令集向量 AI 扩展01Attached Matrix 扩展指令集矩阵 AI 扩展02展望和鸣谢总结01向量 AI 扩展SFU 扩展指令集(Vector Based)Runtime breakdown for BERT-Large on a Volta GPUSoftermax:Hardware/Software Co-Design of an Efficient Softmax for TransformersExponential functionReciprocal functionTangent func
2、tionSigmoid functionSoftMax functionGelu function高密度矩阵计算高密度SFU计算面向 AI 应用的 SFU 扩展向量 SFU 扩展快速算法实现Schraudolph N N.A Fast,Compact Approximation of the Exponential FunctionJ.计算速度快查找表实现Lookup Table ExampleRISC-V Vector Instruction vfrec7.v vfrsqrt7.v实现简单多阶泰勒展开 不同的展开阶数对应不同的精度需求 通过 FMA 的并行计算,可以得到较低的计算延迟 FMA
3、 阵列可以复用 预处理和后处理可以复用精度实现灵活SRCFunc0Look UpTableFunc1Look UpTableFunc2Look UpTableRSLTXFMAFMAFMAFMAa abcd计算速度快实现简单精度实现灵活现有实现方式输入范围Tanh 的具体实现特殊值特殊值-inf,0-tanh(-x),x位于0,+inf0,2(-10)x2(-10),2(-1)分段泰勒展开实现,分为9段0.5,4tanh(x)=2*sigmoid(2*x)-14,+inf1高效计算和资源复用特殊值段特殊映射平衡精度和计算复杂度分段使用不同的展开阶数和参数加速计算使用查找表存储参数分段多阶泰勒展开
4、指令定义助记符vfexp2Output vector 2x of the input vector xvfexp2.v vd,vs2,vmvftanhOutput vector tanh(x)of the input vector xvftanh.v vd,vs2,vmvfsigOutput vector sigmoid(x)of the input vector xvfsig.v vd,vs2,vmvfrecOutput vector 1/x of the input vector xvfrec.v vd,vs2,vm遵循支持简化设计RVV 扩展规则 玄铁自定义扩展指令规则 FP32 的计算
5、 mask 操作 vta/vma 配置 LMUL 操作不支持rounding模式设置,无非精确异常及下溢异常指令定义助记符向量SFU扩展指令集数据采用最高性能配置,SFU 单元面积占用小于 vector 标准模块的 15%Pre ProcessLook UpTable0Look UpTable1Look UpTable2MultiplierUnitFused multiply-accumulation treeC0+C1*X+C2*X2+C3*X3+Post ProcessOutputc0 c1 c2 c3c0 c1 c2 c3c0 c1 c2 c3InputxX2X310.80.60.40.
6、20EXPTANHSIGMOIDwo SFU extensionwi SFU extension90%90%90%75%REC性能提升算力弹性可变 VLEN灵活实现Special Function UnitAcceleration effect of different functions with Xuantie SFU vector extension instructions硬件实现02矩阵 AI 扩展Attached Matrix 扩展指令集Future data types(fp4 fp8 binary)Other matrix operations and features(poi