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 only need to convert types, but not 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 32const uint rs = ne00 * nb00 ; 33//const uint id = i01 + i02 * ne02 + i03 * ne01 * ne02; 34const uint id = ( i03 * ne01 + i02 ) * ne02 + i01 ; 35 36uint rsi = i01 * nb01 + i02 * nb02 + i03 * nb03 ; 37uint rdi = id * rs ; 38 39const uint rsiEnd = rsi + rs ; 40rsi += thread ; 41rdi += thread ; 42for ( ; rsi < rsiEnd ; rsi += 32 , rdi += 32 ) 43{ 44float f = arg0 [ rsi ]; 45[ branch ] 46if ( downcastFp32 ) 47f = adjustFp16 ( f ); 48result [ rdi ] = f ; 49} 50}