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
811 B21 linesraw
1inline uint rowOffset( uint3 idx, uint4 strides )
2{
3	return idx[ 0 ] * strides[ 1 ] + idx[ 1 ] * strides[ 2 ] + idx[ 2 ] * strides[ 3 ];
4}
5
6// Initial iterator state for a row of the output tensor
7// x = current index, y = index increment, z = end of the index
8inline uint3 tensorIteratorState( uint3 group, uint thread, uint4 size, uint4 stride )
9{
10	uint3 res;
11	res.x = rowOffset( group, stride );
12	res.y = THREADS * stride[ 0 ];
13	res.z = res.x + size[ 0 ] * stride[ 0 ];
14	res.x += thread * stride[ 0 ];
15	return res;
16}
17
18// Handle a complete row of output tensor, using the iterator made by tensorIteratorState() function
19#define ROW_LOOP( ts ) for( ; ts.x < ts.z; ts.x += ts.y )
20// Same as above, using different row length
21#define ROW_LOOP_EX( ts, len, stride ) for( ; ts.x < ts.z; ts.x += len * stride[ 0 ] )