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
8c4603c
master
1#pragma warning disableCS0649 2using System . Runtime . InteropServices ; 3 4namespace CompressShaders 5{ 6static class DetectFp64 7{ 8struct DXBCHeader 9{ 10public uint FourCC ; // Four character code "DXBC" 11public uint Hash0 ; // 32-bit hash of the DXBC file 12public uint Hash1 ; // 32-bit hash of the DXBC file 13public uint Hash2 ; // 32-bit hash of the DXBC file 14public uint Hash3 ; // 32-bit hash of the DXBC file 15public uint unknownOne ; 16public uint TotalSize ; // Total size of the DXBC file in bytes 17public int NumChunks ; // Number of chunks in the DXBC file 18} ; 19 20public static bool usesFp64 ( ReadOnlySpan < byte > dxbc ) 21{ 22ReadOnlySpan < DXBCHeader > dxbcHeaderSpan = MemoryMarshal . Cast < byte , DXBCHeader > ( dxbc ); 23DXBCHeader dxbcHeader = dxbcHeaderSpan [ 0 ]; 24 25int cbHeader = Marshal . SizeOf < DXBCHeader > (); 26int nChunks = dxbcHeader . NumChunks ; 27ReadOnlySpan < int > chunkOffsets = MemoryMarshal . Cast < byte , int > ( dxbc . Slice ( cbHeader , nChunks * 4 ) ); 28foreach ( int off in chunkOffsets ) 29{ 30uint id = MemoryMarshal . Cast < byte , uint > ( dxbc . Slice ( off , 4 ) )[ 0 ]; 31const uint SFI0 = 0x30494653 ; 32if ( id != SFI0 ) 33continue ; 34int size = MemoryMarshal . Cast < byte , int > ( dxbc . Slice ( off + 4 , 4 ) )[ 0 ]; 35if ( size < 4 ) 36throw new ApplicationException (); 37uint data = MemoryMarshal . Cast < byte , uint > ( dxbc . Slice ( off + 8 , 4 ) )[ 0 ]; 38return 0 != ( data & 1u ); 39} 40return false ; 41} 42} 43}