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

KonstantinSource codes8c4603c

master
1.1 KiB41 linesraw
1// Matrix * scalar product, like [ 1, E1, E2, E3 ] * [ 1, 1, E2, E3 ] = [ E1, 1, E2, E3 ]
2// Dispatch [ E2, E3, 1 ] thread groups of this shader
3Buffer<float> arg0: register( t0 );
4Buffer<float> arg1: register( t1 );
5RWBuffer<float> result: register( u0 );
6
7cbuffer Constants: register( b0 )
8{
9	uint4 arg0Size: packoffset( c0 );
10	uint4 arg0Strides: packoffset( c1 );
11	uint4 arg1Size: packoffset( c2 );
12	uint4 arg1Strides: packoffset( c3 );
13	uint4 resultSize: packoffset( c4 );
14	uint4 resultStrides: packoffset( c5 );
15}
16
17inline uint hadd( uint2 vec )
18{
19	return vec.x + vec.y;
20}
21
22[ numthreads( 32, 1, 1 ) ]
23void main( uint3 group: SV_GroupID, uint thread : SV_GroupIndex )
24{
25	const float scalarValue = arg1[ hadd( group.xy * arg1Strides.zw ) ];
26
27	uint s0 = hadd( group.xy * arg0Strides.zw );
28	const uint s0Inc = 32 * arg0Strides.y;
29	s0 += thread * arg0Strides.y;
30
31	uint rdi = hadd( group.xy * resultStrides.zw );
32	const uint rdiEnd = rdi + arg0Size.y;
33	rdi += thread;
34
35	for( ; rdi < rdiEnd; rdi += 32, s0 += s0Inc )
36	{
37		float f = arg0[ s0 ];
38		f *= scalarValue;
39		result[ rdi ] = f;
40	}
41}