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 KiB50 linesraw
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{
8	uint4 src0_elements: packoffset( c0 );
9	uint4 src0_strides: packoffset( c1 );
10	bool 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{
18	const uint nb00 = src0_strides[ 0 ];
19	const uint nb01 = src0_strides[ 1 ];
20	const uint nb02 = src0_strides[ 2 ];
21	const uint nb03 = src0_strides[ 3 ];
22
23	const uint ne00 = src0_elements[ 0 ];
24	const uint ne01 = src0_elements[ 1 ];
25	const uint ne02 = src0_elements[ 2 ];
26	const uint ne03 = src0_elements[ 3 ];
27
28	const uint i01 = group.x;
29	const uint i02 = group.y;
30	const uint i03 = group.z;
31
32	const uint rs = ne00 * nb00;
33	//const uint id = i01 + i02 * ne02 + i03 * ne01 * ne02;
34	const uint id = ( i03 * ne01 + i02 ) * ne02 + i01;
35
36	uint rsi = i01 * nb01 + i02 * nb02 + i03 * nb03;
37	uint rdi = id * rs;
38
39	const uint rsiEnd = rsi + rs;
40	rsi += thread;
41	rdi += thread;
42	for( ; rsi < rsiEnd; rsi += 32, rdi += 32 )
43	{
44		float f = arg0[ rsi ];
45		[branch]
46		if( downcastFp32 )
47			f = adjustFp16( f );
48		result[ rdi ] = f;
49	}
50}