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

KonstantinSource codes8c4603c

master
529 B19 linesraw
1#include "stdafx.h"
2#include "KvTensors.h"
3using namespace CpuCompute;
4
5// Create these two large tensors, FP16 precision
6HRESULT KvTensors::create( const Whisper::sModelParams& mp )
7{
8	const uint32_t n_mem = mp.n_text_layer * mp.n_text_ctx;
9	const uint32_t n_elements = mp.n_text_state * n_mem;
10
11	const size_t cb = sizeof( uint16_t ) * (size_t)n_elements * 2;
12	CHECK( memory.allocate( cb ) );
13
14	uint16_t* pointer = (uint16_t*)memory.pointer();
15	keys = pointer;
16	values = pointer + n_elements;
17	size = n_elements;
18	return S_OK;
19}