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.3 KiB49 linesraw
1// Matrix * row product, like [ E0, E1, E2, E3 ] * [ E0, 1, E2, E3 ] = [ E1, 1, E2, E3 ]
2// Dispatch [ E1, E2, E3 ] 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
17#include "groupReduce.hlsli"
18
19inline uint hadd( uint3 vec )
20{
21	return vec.x + vec.y + vec.z;
22}
23inline uint hadd( uint2 vec )
24{
25	return vec.x + vec.y;
26}
27
28[ numthreads( 32, 1, 1 ) ]
29void main( uint3 group: SV_GroupID, uint thread : SV_GroupIndex )
30{
31	uint s0 = hadd( group * arg0Strides.yzw );
32	uint s1 = hadd( group.yz * arg1Strides.zw );
33	const uint s0End = s0 + arg0Size.x * arg0Strides.x;
34	const uint s0Inc = 32 * arg0Strides.x;
35	const uint s1Inc = 32 * arg1Strides.x;
36
37	s0 += thread * arg0Strides.x;
38	s1 += thread * arg1Strides.x;
39	float dp = 0;
40	for( ; s0 < s0End; s0 += s0Inc, s1 += s1Inc )
41		dp = mad( arg0[ s0 ], arg1[ s1 ], dp );
42
43	horizontalSum( thread, dp );
44	if( 0 != thread )
45		return;
46
47	const uint rdi = group.x + hadd( group.yz * resultStrides.zw );
48	result[ rdi ] = dp;
49}