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
894 B28 linesraw
1// TODO: compile another version of these shader, and use it on GPUs with ExtendedDoublesShaderInstructions flag, will become slightly faster
2// https://learn.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_feature_data_d3d11_options
3#ifndef ExtendedDoublesShaderInstructions
4#define ExtendedDoublesShaderInstructions 0
5#endif
6
7// Compute num/den in FP64 precision
8inline double div64( double num, double den )
9{
10#if ExtendedDoublesShaderInstructions
11	return num / den;
12#else
13	// https://en.wikipedia.org/wiki/Division_algorithm#Newton%E2%80%93Raphson_division
14	double x = 1.0f / (float)den;
15	x += x * ( 1.0 - den * x );
16	x += x * ( 1.0 - den * x );
17	return num * x;
18#endif
19}
20
21// Compute sqrt(x) in FP64 precision
22inline double sqrt64( double x )
23{
24	double root = sqrt( (float)x );
25	root = 0.5 * ( root + div64( x, root ) );
26	root = 0.5 * ( root + div64( x, root ) );
27	return root;
28}