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 once 2#include "../D3D/downloadBuffer.h" 3#include "../D3D/RenderDoc/renderDoc.h" 4#include <unordered_set> 5#include <functional> 6 7// Funfact: this code written by ChatGPT 8namespace std 9{ 10template <> 11struct hash < array < uint32_t ,8 >> 12 { 13size_t operator ()(const array < uint32_t ,8 >& arr )const 14 { 15size_t result = 0 ; 16for (uint32_t element :arr ) 17result = (result * 31 ) ^element ; 18return result ; 19 } 20 }; 21} 22 23namespace DirectCompute 24{ 25struct sTensorDiff 26 { 27// maximum( absolute( a - b ) ) 28float maxAbsDiff ; 29// average( ( a - b )^2 ) 30float avgDiffSquared ; 31size_t length ; 32 33void const ; 34void const char * what )const ; 35 }; 36 37// Compute difference between 2 FP32 vectors 38sTensorDiff computeDiff (const float * a ,const float * b ,size_t length ); 39 40// Compute difference between 2 FP16 vectors 41sTensorDiff computeDiff (const uint16_t * a ,const uint16_t * b ,size_t length ); 42 43class Tensor ; 44sTensorDiff computeDiff (const Tensor & a ,const Tensor & b ); 45 46HRESULT dbgWriteBinaryFile (LPCTSTR fileName ,const void * rsi ,size_t cb ); 47 48// Print unique sizes of the two tensors 49class PrintUniqueTensorSizes 50 { 51std ::unordered_set < std ::array < uint32_t ,8 >>set ; 52const char * const what ; 53void printImpl (const std ::array < uint32_t ,8 >& a ); 54 55public : 56PrintUniqueTensorSizes (const char * w ) :what (w ) { } 57 58void const Tensor & lhs ,const Tensor & rhs ); 59void const Tensor & lhs ); 60void const int * lhs ,const int * rhs ); 61 }; 62}