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_conv_1d_2s_f16_f32, GGML_TASK_COMPUTE implementation 2// Dispatch [ ne10 / 2, ne02, 1 ] thread groups 3Buffer < float > arg0 :register ( t0 ); 4Buffer < float > arg1 :register ( t1 ); 5RWBuffer < float > result :register ( u0 ); 6 7cbuffer Constants :register ( b0 ) 8{ 9uint4 src0_elements :packoffset ( c0 ); 10uint4 src0_strides :packoffset ( c1 ); 11uint4 src1_elements :packoffset ( c2 ); 12uint4 result_elements :packoffset ( c4 ); 13uint4 result_strides :packoffset ( c5 ); 14} 15 16#include "groupReduce.hlsli" 17 18inline void computeDotProduct ( uint s0 , uint s1 , uint len , uint thread , inout float acc ) 19{ 20float curr = 0 ; 21const uint s0End = s0 + len ; 22s0 += thread ; 23s1 += thread ; 24for ( ; s0 < s0End ; s0 += 32 , s1 += 32 ) 25curr = mad ( arg0 [ s0 ], arg1 [ s1 ], curr ); 26 27horizontalSumCompatNew ( thread , curr ); 28if ( 0 == thread ) 29acc += curr ; 30} 31 32#include "miscUtils.hlsli" 33 34[ numthreads ( 32 , 1 , 1 ) ] 35void main ( uint3 group : SV_GroupID , uint thread : SV_GroupIndex ) 36{ 37const uint ne00 = src0_elements [ 0 ]; 38const uint ne01 = src0_elements [ 1 ]; 39const int ew0 = roundUp32 ( ne01 ); 40 41float res = 0 ; 42uint s0 = group . y * ew0 * ne00 ; 43uint s1 = group . x * 2 * ew0 ; 44// The original implementation did following: 45// int nh = (int)( nk / 2 ); 46// for( int k = -nh; k <= nh; k++ ) 47// What we doing instead: 48// for( uint len = ( nk / 2 ) * 2 + 1, i = 0; i < len; i++ ) 49// len = ( nk / 2 ) * 2 + 1 is equal to ( nk | 1 ) 50const uint s0End = s0 + ( ne00 | 1u ) * ew0 ; 51for ( ; s0 < s0End ; s0 += ew0 , s1 += ew0 ) 52computeDotProduct ( s0 , s1 , ew0 , thread , res ); 53 54if ( 0 != thread ) 55return ; 56 57const uint nb1 = result_strides [ 1 ]; 58const uint rdi = group . y * nb1 + group . x ; 59result [ rdi ] = res ; 60}