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
1.6 KiB55 linesraw
1#pragma once
2#include <array>
3#include <emmintrin.h>
4#include "../../D3D/enums.h"
5
6namespace Tracing
7{
8	using DirectCompute::eDataType;
9
10	// File header of the trace file
11	struct sFileHeader
12	{
13		static constexpr uint32_t correctMagic = 0xE6B4A12Du;	// random.org
14
15		uint32_t magic;
16		uint8_t formatVersion;
17		uint8_t zzPadding;
18		uint16_t cbItem;
19		uint32_t countItems;
20		uint32_t zzPadding2;
21		uint64_t bytesPayload;
22		uint32_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
32	enum struct eItemType : uint8_t
33	{
34		Buffer = 1,
35		Tensor = 2,
36	};
37
38	struct sTraceItem
39	{
40		uint64_t payloadOffset;
41		uint64_t payloadSize;
42		std::array<uint32_t, 4> size;
43		std::array<uint32_t, 4> stride;
44		std::array<uint32_t, 4> formatArgs;
45		eItemType itemType;
46		eDataType dataType;
47		uint8_t countFormatArgs = 0;
48		uint8_t zzPadding = 0;
49		uint32_t stringIndex;
50
51		uint64_t buffer( uint64_t off, size_t length, eDataType type );
52
53		uint64_t tensor( uint64_t off, __m128i ne, __m128i nb, eDataType type );
54	};
55}