yum-archive/TaSTT-Whisper
High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model
git clone https://git.yummers.dev/yum-archive/TaSTT-Whisper
8c4603c
master
1// ggml_compute_forward_dup_f32 when we actually need to reshape the tensor 2// Dispatch [ ne01, ne02, ne03 ] thread groups of this shader 3Buffer < float > arg0 :register ( t0 ); 4RWBuffer < float > result :register ( u0 ); 5 6cbuffer Constants :register ( b0 ) 7{ 8uint4 src0_elements :packoffset ( c0 ); 9uint4 src0_strides :packoffset ( c1 ); 10bool downcastFp32 :packoffset ( c2 . x ); 11} 12 13#include "miscUtils.hlsli" 14 15[ numthreads ( 32 , 1 , 1 ) ] 16void main ( uint3 group : SV_GroupID , uint thread : SV_GroupIndex ) 17{ 18const uint nb00 = src0_strides [ 0 ]; 19const uint nb01 = src0_strides [ 1 ]; 20const uint nb02 = src0_strides [ 2 ]; 21const uint nb03 = src0_strides [ 3 ]; 22 23const uint ne00 = src0_elements [ 0 ]; 24const uint ne01 = src0_elements [ 1 ]; 25const uint ne02 = src0_elements [ 2 ]; 26const uint ne03 = src0_elements [ 3 ]; 27 28const uint i01 = group . x ; 29const uint i02 = group . y ; 30const uint i03 = group . z ; 31 32// We need following integer: i01*ne00 + i02*ne00*ne01 + i03*ne00*ne01*ne02 33// We want to minimize count of integer multiplications 34// Also, DXBC assembly features `imad` instruction which computes a*b+c for integers, the actual hardware hopefully has an equivalent 35// i03*ne00*ne01*ne02 + i02*ne00*ne01 + i01*ne00 36// ( i03*ne01*ne02 + i02*ne01 + i01 ) * ne00 37// ( ( i03*ne02 + i02) * ne01 + i01 ) * ne00 38uint rdi = ( ( i03 * ne02 + i02 ) * ne01 + i01 ) * ne00 ; 39 40const uint rdiEnd = rdi + ne00 ; 41 42uint rsi = i01 * nb01 + i02 * nb02 + i03 * nb03 ; 43const uint rsiInc = 32 * nb00 ; 44 45rdi += thread ; 46rsi += thread * nb00 ; 47 48for ( ; rdi < rdiEnd ; rdi += 32 , rsi += rsiInc ) 49{ 50float f = arg0 [ rsi ]; 51[ branch ] 52if ( downcastFp32 ) 53f = adjustFp16 ( f ); 54result [ rdi ] = f ; 55} 56}