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_1s_f16_f32, GGML_TASK_COMPUTE implementation 2// Dispatch [ ne10, 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 completeVectors = len / 32 ; 22uint i ; 23for ( i = 0 ; i < completeVectors ; i ++ , s0 += 32 , s1 += 32 ) 24curr = mad ( arg0 [ s0 + thread ], arg1 [ s1 + thread ], curr ); 25 26horizontalSumCompatNew ( thread , curr ); 27 28if ( 0 == thread ) 29{ 30const uint rem = len % 32 ; 31if ( 0 != rem ) 32{ 33double f64 = curr ; 34for ( i = 0 ; i < rem ; i ++ ) 35{ 36 precisefloat a = arg0 [ s0 + i ]; 37 precisefloat b = arg1 [ s1 + i ]; 38 precisefloat prod = a * b ; 39f64 += prod ; 40} 41curr = ( float ) f64 ; 42} 43acc += curr ; 44} 45} 46 47#include "miscUtils.hlsli" 48 49[ numthreads ( 32 , 1 , 1 ) ] 50void main ( uint3 group : SV_GroupID , uint thread : SV_GroupIndex ) 51{ 52const uint i1 = group . y ; 53const uint i0 = group . x ; 54 55const uint ne00 = src0_elements [ 0 ]; 56const uint nk = ne00 ; 57const int nh = ( int )( nk / 2 ); 58 59const uint ne01 = src0_elements [ 1 ]; 60const int ew0 = roundUp32 ( ne01 ); 61 62float res = 0 ; 63for ( int k = - nh ; k <= nh ; k ++ ) 64{ 65const uint source0 = i1 * ew0 * ne00 + uint ( nh + k ) * ew0 ; 66const uint source1 = uint ( i0 + nh + k ) * ew0 ; 67computeDotProduct ( source0 , source1 , ew0 , thread , res ); 68} 69 70if ( 0 != thread ) 71return ; 72 73const uint nb1 = result_strides [ 1 ]; 74const uint rdi = i1 * nb1 + i0 ; 75result [ rdi ] = res ; 76}