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 <array> 3#include <emmintrin.h> 4#include "../../D3D/enums.h" 5 6namespace Tracing 7{ 8using DirectCompute ::eDataType ; 9 10// File header of the trace file 11struct sFileHeader 12 { 13static constexpruint32_t correctMagic = 0xE6B4A12Du ;// random.org 14 15uint32_t magic ; 16uint8_t formatVersion ; 17uint8_t zzPadding ; 18uint16_t cbItem ; 19uint32_t countItems ; 20uint32_t zzPadding2 ; 21uint64_t bytesPayload ; 22uint32_t countStrings ,bytesStrings ; 23 }; 24// Payload data starts immediately after the header, bytesPayload bytes in total. 25// Then `bytesStrings` with string names, first countStrings * 4 of them are offsets, then ( bytesStrings - countStrings * 4 ) bytes with the string data. 26// The strings in the file are null-terminated. 27// Immediately after the strings, the next `cbItem` * `countItems` bytes are actual items (tensors and vectors) saved in the trace. 28// The format is weird because optimized for streaming. 29// These traces can grow large, we can’t afford memory keeping the payload data in memory. 30// Metadata is tiny compared to payload, we accumulate that in memory, and write to the end of the file when closed. 31 32enum struct eItemType :uint8_t 33 { 34Buffer = 1 , 35Tensor = 2 , 36 }; 37 38struct sTraceItem 39 { 40uint64_t payloadOffset ; 41uint64_t payloadSize ; 42std ::array < uint32_t ,4 > size ; 43std ::array < uint32_t ,4 > stride ; 44std ::array < uint32_t ,4 > formatArgs ; 45eItemType itemType ; 46eDataType dataType ; 47uint8_t countFormatArgs = 0 ; 48uint8_t zzPadding = 0 ; 49uint32_t stringIndex ; 50 51uint64_t buffer (uint64_t off ,size_t length ,eDataType type ); 52 53uint64_t tensor (uint64_t off ,__m128i ne ,__m128i nb ,eDataType type ); 54 }; 55}