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 "MappedResource.h" 3using namespace DirectCompute ; 4#define CHECK (hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; } 5 6MappedResource ::MappedResource () 7{ 8mapped .pData = nullptr ; 9mapped .RowPitch = mapped .DepthPitch = 0 ; 10resource = nullptr ; 11} 12 13HRESULT MappedResource ::map (ID3D11Resource * res ,bool reading ) 14{ 15if (nullptr == resource ) 16 { 17D3D11_MAP mt = reading ?D3D11_MAP_READ :D3D11_MAP_WRITE_DISCARD ; 18CHECK (context ()-> Map (res ,0 ,mt ,0 ,& mapped ) ); 19resource = res ; 20return S_OK ; 21 } 22return HRESULT_FROM_WIN32 (ERROR_ALREADY_INITIALIZED ); 23} 24 25MappedResource ::~MappedResource () 26{ 27if (nullptr != resource ) 28 { 29context ()-> Unmap (resource ,0 ); 30resource = nullptr ; 31mapped .pData = nullptr ; 32 } 33}