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#ifndef THREADS 2#define THREADS 256 3#endif 4 5// dec.tokenEmbedding tensor 6Buffer < float > tokenEmbedding :register ( t0 ); 7// dec.positionalEmbedding tensor 8Buffer < float > positionalEmbedding :register ( t1 ); 9// R32_UINT buffer with the input tokens 10Buffer < uint > embd :register ( t2 ); 11// Output tensor 12RWBuffer < float > result :register ( u0 ); 13 14cbuffer Constants :register ( b0 ) 15{ 16uint rowLength :packoffset ( c0 . x ); 17uint pastTokensCount :packoffset ( c0 . y ); 18uint outputRowStride :packoffset ( c0 . z ); 19uint2 embStrides :packoffset ( c1 . x ); 20uint2 posStrides :packoffset ( c1 . z ); 21} 22 23[ numthreads ( THREADS , 1 , 1 ) ] 24void main ( uint3 group : SV_GroupID , uint thread : SV_GroupIndex ) 25{ 26const uint row = group . x ; 27const uint rowTok = embd [ row ]; 28const uint rowPos = row + pastTokensCount ; 29 30uint rdi = row * outputRowStride ; 31const uint rdiEnd = rdi + rowLength ; 32rdi += thread ; 33 34uint rsiTok = rowTok * embStrides . y ; 35rsiTok += thread * embStrides . x ; 36 37uint rsiPos = rowPos * posStrides . y ; 38rsiPos += thread * posStrides . x ; 39 40for ( ; rdi < rdiEnd ; rdi += THREADS , rsiTok += THREADS * embStrides . x , rsiPos += THREADS * posStrides . x ) 41{ 42float a = tokenEmbedding [ rsiTok ]; 43float b = positionalEmbedding [ rsiPos ]; 44result [ rdi ] = a + b ; 45} 46}