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#include "stdafx.h" 2#include "KeyValueDownloader.h" 3 4HRESULT KeyValueDownloader ::create (const Whisper ::sModelParams & mp ) 5{ 6const uint32_t n_audio_ctx = mp .n_audio_ctx ; 7const uint32_t n_mem = mp .n_text_layer * mp .n_audio_ctx ; 8const uint32_t n_elements = mp .n_text_state * n_mem ; 9 10CD3D11_BUFFER_DESC desc {n_elements * 2 ,0 ,D3D11_USAGE_STAGING ,D3D11_CPU_ACCESS_READ }; 11ID3D11Device * dev = DirectCompute ::device (); 12CHECK (dev -> CreateBuffer (& desc ,nullptr ,& keys ) ); 13CHECK (dev -> CreateBuffer (& desc ,nullptr ,& values ) ); 14 15length = n_elements ; 16return S_OK ; 17} 18 19HRESULT KeyValueDownloader ::download (const DirectCompute ::KeyValueBuffers & source ) 20{ 21ID3D11DeviceContext * ctx = DirectCompute ::context (); 22ctx -> CopyResource (keys ,source .keys .getBuffer () ); 23ctx -> CopyResource (values ,source .values .getBuffer () ); 24return S_OK ; 25} 26 27KeyValueDownloader ::ReadMap ::ReadMap (KeyValueDownloader & owner ) : 28length (owner .length ) 29{ 30check (mappedKeys .map (owner .keys , true ) ); 31check (mappedValues .map (owner .values , true ) ); 32}