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 "Tensor.h" 3#include "LargeBuffer.h" 4#include "../Whisper/sModelParams.h" 5 6namespace CpuCompute 7{ 8class KvTensors 9 { 10uint16_t * keys = nullptr ; 11uint16_t * values = nullptr ; 12uint32_t size = 0 ; 13 14CpuCompute ::LargeBuffer memory ; 15 16public : 17// Create these two large tensors, FP16 precision 18HRESULT create (const Whisper ::sModelParams & mp ); 19 20// A slice of model.memory_cross_k tensor 21Tensor keysView (uint32_t len ,uint32_t off )const 22 { 23if (len + off <=size ) 24return Tensor ::fromData (keys + off ,eDataType ::FP16 ,len ); 25throw E_BOUNDS ; 26 } 27 28// A slice of model.memory_cross_v tensor 29Tensor valuesView (uint32_t len ,uint32_t off )const 30 { 31if (len + off <=size ) 32return Tensor ::fromData (values + off ,eDataType ::FP16 ,len ); 33throw E_BOUNDS ; 34 } 35 }; 36}