text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|> m_hWnd );
if( state.boolLoad( regValTranslate ) )
::SendMessage( m_hWnd, BM_SETCHECK, BST_CHECKED, 0L );
}
bool TranslateCheckbox::checked()
{
assert( nullptr != m_hWnd );
const int state = ( int )::SendMessage( m_hWnd, BM_GETCHECK, 0, 0 );
return state == BST_CHECKED;
}
void TranslateCheckbox::... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ed();
void saveSelection( AppState& state );
};<|fim_prefix|>#pragma once
#include "../AppState.h"
class TranslateCheckbox
{
HWND m_hWn<|fim_middle|>d = nullptr;
public:
operator HWND() const
{
return m_hWnd;
}
void initialize( HWND owner, int idc, AppState& state );
bool check<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_prefix|>// Windows Template Library - WTL version 10.0
// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Public License (http://opensource.org/license... | fim | Const-me/Whisper | c |
<|fim_prefix|>// Windows Template Library - WTL version 10.0
// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Public License (http://opensource.org/license... | fim | Const-me/Whisper | c |
<|fim_suffix|>:SetFocus(pT->GetDlgItem(nCtrlID));
}
void OnDataValidateError(UINT nCtrlID, BOOL /*bSave*/, _XData& /*data*/)
{
// Override to display an error message
::MessageBeep((UINT)-1);
T* pT = static_cast<T*>(this);
::SetFocus(pT->GetDlgItem(nCtrlID));
}
};
} // namespace WTL
#endif // __ATLDDX_H_... | fim | Const-me/Whisper | c |
// Windows Template Library - WTL version 10.0
// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Public License (http://opensource.org/licenses/MS-PL)
// wh... | fim | Const-me/Whisper | c |
<|fim_prefix|>// Windows Template Library - WTL version 10.0
// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Public License (http://opensource.org/license... | fim | Const-me/Whisper | c |
// Windows Template Library - WTL version 10.0
// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Public License (http://opensource.org/licenses/MS-PL)
// wh... | fim | Const-me/Whisper | c |
<|fim_suffix|> - extension of ATL::CWindow
namespace WTL
{
class CWindowEx : public ATL::CWindow
{
public:
CWindowEx(HWND hWnd = NULL) : ATL::CWindow(hWnd)
{ }
CWindowEx& operator =(HWND hWnd)
{
m_hWnd = hWnd;
return *this;
}
operator HWND() const
{
return m_hWnd;
}
// Methods
BOOL PrintWindow(HDC h... | fim | Const-me/Whisper | c |
<|fim_suffix|>ngth ) );
const size_t len = length.countSegments;
size_t i = len - newSegments;
const sSegment* const segments = results->getSegments();
const sToken* const tokens = results->getTokens();
CStringA str;
for( ; i < len; i++ )
{
const sSegment& seg = segments[ i ];
str = "[";
printTime( str,... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>L( Whisper::eLogLevel::Debug );
}
#undef LOG_MESSAGE_IMPL
HRESULT logNewSegments( const Whisper::iTranscribeResult* results, size_t newSegments, bool printSpecial = false );
void clearLastError();
bool getLastError( CString& rdi );
void printTime( CStringA& rdi, Whisper::sTimeSpan time, bool comma = f... | fim | Const-me/Whisper | c |
<|fim_suffix|>tError( HWND owner, LPCTSTR text, LPCTSTR title, HRESULT hr )
{
if( nullptr == title )
title = L"Operation Failed";
CString message = text;
message.TrimRight();
if( FAILED( hr ) )
{
message += L"\n";
message += formatErrorMessage( hr );
}
::MessageBox( owner, message, title, MB_OK | MB_ICON... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include <iContext.h>
#include "logger.h"
CString formatErrorMessage( HRESULT hr );
void reportFatalError( const char* what, HRESULT hr );
#define CHECK( hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; }
HRESULT implParse( const CString& s, Whisper::eModelImplementat... | fim | Const-me/Whisper | c |
<|fim_suffix|>urn hr;
}
static HRESULT dialogTranscribe( AppState& appState )
{
TranscribeDlg dialog{ appState };
return dialog.show();
}
static HRESULT dialogCapture( AppState& appState )
{
CaptureDlg dialog{ appState };
return dialog.show();
}
using pfnDialog = HRESULT( * )( AppState& appState );
static const ... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>h>
#include <atlbase.h>
#include <atlwin.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <assert.h>
// C++ headers
#include <vector>
#include <array>
#include <algorithm><|fim_prefix|>#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude ... | fim | Const-me/Whisper | c |
<|fim_suffix|><|fim_prefix|>#inc<|fim_middle|>lude "stdafx.h"<|endoftext|> | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ls/WTL/atlapp.h"
#include "Utils/WTL/atlctrls.h"<|fim_prefix|>#pragma once
#include "framework.h"
#include <<|fim_middle|>whisperWindows.h>
#include "resource.h"
#include "Uti<|endoftext|> | fim | Const-me/Whisper | c |
#pragma once
// Setup Windows SDK to only enable features available since Windows 8.0
#include <WinSDKVer.h>
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#define NTDDI_VERSION NTDDI_WIN8
#include <SDKDDKVer.h>
<|endoftext|> | fim | Const-me/Whisper | c |
__declspec( dllexport ) int NvOptimusEnablement = 1;
__declspec( dllexport ) int AmdPowerXpressRequestHighPerformance = 1;<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "params.h"
#include "../../Whisper/API/iContext.cl.h"
#include "../../Whisper/API/iMediaFoundation.cl.h"
#include "../../ComLightLib/comLightClient.h"
#include "miscUtils.h"
#include <array>
#include <atomic>
#include "textWriter.h"
using namespace Whisper;
#define STREAM_AUDIO 1
static HRESULT... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#include "miscUtils.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
std::string utf8( const std::wstring& utf16 )
{
int count = WideCharToMultiByte( CP_UTF8, 0, utf16.c_str(), (int)utf16.length(), nullptr, 0, nullptr, nullptr );
std::string str( count, 0 );
WideCharToMultiByte( CP_UTF8, 0, utf16.c... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ng& u8 );
using HRESULT = long;
void printError( const char* what, HRESULT hr );<|fim_prefix|>#pragma once
#include <string>
std::string utf8( const std<|fim_middle|>::wstring& utf16 );
std::wstring utf16( const std::stri<|endoftext|> | fim | Const-me/Whisper | c |
#include "params.h"
#include <algorithm>
#include <thread>
#include "miscUtils.h"
#include "../../Whisper/API/iContext.cl.h"
whisper_params::whisper_params()
{
#ifdef _DEBUG
n_threads = 2;
#else
n_threads = std::min( 4u, std::thread::hardware_concurrency() );
#endif
}
namespace
{
const char* cstr( bool b )
{
r... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>pt;
std::vector<std::wstring> fname_inp;
whisper_params();
bool parse( int argc, wchar_t* argv[] );
};
void whisper_print_usage( int argc, wchar_t** argv, const whisper_params& params );<|fim_prefix|>#pragma once
#include <vector>
#include <string>
<|fim_middle|>// command-line parameters
struct wh... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "textWriter.h"
#include "../../Com<|fim_suffix|>sSegment& seg = segments[ i ];
if( timestamps )
{
line = "[";
printTime( line, seg.time.begin );
line += " --> ";
printTime( line, seg.time.end );
line += "] ";
}
else
line = "";
line += skipBlank... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "../../Whisper/API/iContext.cl.h"
// These functions print output segments into text files of various formats
HRESULT writeText( Whis<|fim_suffix|> LPCTSTR audioPath, bool timestamps );
HRESULT writeSubRip( Whisper::iContext* context, LPCTSTR audioPath );
HRESULT writeWebVTT( Whispe... | fim | Const-me/Whisper | c |
<|fim_prefix|>using System.ComponentModel;
using System.Runtime.InteropServices;
namespace CompressShaders
{
/// <summary>Lossless data compressor implemented by <c>Cabinet.dll</c> Windows component</summary>
/// <remarks>
/// <para>That compression API was introduced in Windows 8.0, and is the only reason why the... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Runtime.CompilerServices;
namespace CompressShaders;
record struct sShaderBinary
{
public string name;
public byte[] data;
public sShaderBinary( string path )
{
name = Path.GetFileNameWithoutExtension( path );
data = File.ReadAllBytes( path );
}
public bool wave6<|fim_suffix|>.L... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>st<byte, uint>( dxbc.Slice( off + 8, 4 ) )[ 0 ];
return 0 != ( data & 1u );
}
return false;
}
}
}<|fim_prefix|>#pragma warning disable CS0649
using System.Runtime.InteropServices;
namespace CompressShaders
{
static class DetectFp64
{
struct DXBCHeader
{
public uint FourCC; // Four ... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>ly when not using FAST mode, while decompression speed stays the same
// Actually, it is usually faster for high compression levels as there is less data to process
// https://github.com/MiloszKrajewski/K4os.Compression.LZ4#compression-levels
const LZ4Level compressionLevel = LZ4Level.L12_MAX;
public... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Globalization;
using System.Text.RegularExpressions;
namespace CompressShaders
{
static class LanguageCodes
{
record struct Row
{
public string keySource;
public uint keyValue;
public int code;
public string name;
}
static uint makeKey( string str )
{
if( str.Len... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>static class ShaderNames
{
public static void write( string path, IEnumerable<<|fim_suffix|>const char*, {0}> s_shaderNames = ", arr.Length );
stream.WriteLine( "{" );
foreach( string name in arr )
stream.WriteLine( @" ""{0}"",", name );
stream.Write( @"};
const char* DirectCompute::computeSh... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>namespace CompressTables;
using CompressShaders;
using System.IO;
using System.Runtime.CompilerServices;
/// <summary>Utility app to compress lookup tables data with LZ4-HC, and generate C++ source with the data</summary>
internal<|fim_suffix|> Main( string[] args )
{
byte[] source = File.ReadAllByte... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Globalization;
using System.Text.RegularExpressions;
namespace PerfSummary
{
enum eInputClip: byte
{
jfk,
columbia,
}
enum eWhisperModel: byte
{
medium,
large
}
struct LogName
{
public readonly eInputClip clip;
public readonly eWhisperModel model;
public readonly stri... | fim | Const-me/Whisper | csharp |
<|fim_suffix|>me.clip )
.ThenBy( x => x.name.model )
.ThenBy( x => x.name.gpu )
.ToArray();
Summary.print( logs, root );
}
}
}<|fim_prefix|>using System.Runtime.CompilerServices;
namespace PerfSummary
{
internal class Program
{
static string getSolutionRoot( [CallerFilePath] string? path = null... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>using System.Globalization;
namespace PerfSummary
{
static class Summary
{
public static void print( LogData[] logs, string folder )
{
string path = Path.Combine( folder, "summary.tsv" );
using var writer = File.CreateText( path );
string[] header = new string[]
{
"Audio Clip", "M... | fim | Const-me/Whisper | csharp |
<|fim_prefix|>#include "stdafx.h"
#include "CommandLineArgs.h"
#include <charconv>
static bool printUsage()
{
fprintf( stderr, "Usage: compareTraces.exe trace1.bin trace2.bin [-diff N]\n" );
return false;
}
bool CommandLineArgs::parse( int argc, wchar_t* argv[] )
{
size_t idx = 0;
CString sw;
CStringA tmp;
for(... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
struct CommandLineArgs
{
int64_t printDiff = -1;
s<|fim_suffix|>] );
};<|fim_middle|>td::array<CString, 2> inputs;
bool parse( int argc, wchar_t* argv[<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_suffix|>i;
if( header.magic != header.correctMagic )
return E_INVALIDARG;
countItems = header.countItems;
countStrings = header.countStrings;
rsi += sizeof( sFileHeader );
payloadPointer = rsi;
rsi += header.bytesPayload;
stringIndex = (const uint32_t*)( rsi );
stringData = (const char*)( rsi + countS... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>t sTraceItem& item ) const;
const void* payload( const sTraceItem& item ) const
{
return payloadPointer + item.payloadOffset;
}
};
}<|fim_prefix|>#pragma once
#include "../../Whisper/Utils/Trace/TraceStructures.h"
#include <atlstr.h>
#include <atlfile.h>
names<|fim_middle|>pace Tracing
{
clas... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "../../Whisper/API/iContext.cl.h"
#include "TraceReader.h"
#include "../../Whisper/ML/testUtils.h"
#include "compare.h"
using namespace Tracing;
using namespace DirectCompute;
namespace
{
inline const char* cstr( eItemType it )
{
switch( it )
{
case eItemType::Buffer:... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ineArgs& arguments );<|fim_prefix|>#pragma once
#include "CommandLineArgs.h"
HRESULT compareTraces( const<|fim_middle|> CommandL<|endoftext|> | fim | Const-me/Whisper | c |
#include "stdafx.h"
#include <stdio.h>
#include "compare.h"
#include "CommandLineArgs.h"
int wmain( int argc, wchar_t* argv[] )
{
CommandLineArgs cla;
if( !cla.parse( argc, argv ) )
return 1;
HRESULT hr = compareTraces( cla );
if( SUCCEEDED( hr ) )
return 0;
return hr;
}<|endoftext|> | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#include "stdafx.h"
namespace
{
wchar_t* formatMessage( HRESULT hr )
{
wchar_t* err;
if( FormatMessage( FORMAT_MESSAGE_ALLOC<|fim_suffix|> );
}
else
fprintf( stderr, "Error code %i (0x%08X)\n", hr, hr );
}<|fim_middle|>ATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
hr,
MAKELANGID( LANG... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include <|fim_suffix|>t char* cstr( const CStringA& s ) { return s; }
inline const wchar_t* cstr( const CString& s ) { return s; }<|fim_middle|><stdint.h>
#include <assert.h>
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <atlstr.h>
#include <d3d11.h>
#include <... | fim | Const-me/Whisper | c |
<|fim_suffix|>s( y );
break;
case 2:
low1 = loadFloat2( x );
low2 = loadFloat2( y );
break;
case 3:
low1 = loadFloat3( x );
low2 = loadFloat3( y );
break;
case 4:
low1 = _mm_loadu_ps( x );
low2 = _mm_loadu_ps( y );
break;
case 5:
low1 = _mm_loadu_ps( x );
low2 = _mm_loadu_ps(... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>CaptureStatus : uint8_t
{
Listening = 1,
Voice = 2,
Transcribing = 4,
Stalled = 0x80,
};
// Return S_OK to continue, or S_FALSE to stop the capture session
using pfnShouldCancel = HRESULT( __stdcall* )( void* pv ) noexcept;
using pfnCaptureStatus = HRESULT( __stdcall* )( void* pv, eCaptureS... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
namespace Whisper
{
struct SpecialTokens
{
// The end of a transcription, token_eot
int TranscriptionEnd;
// Start of a transcription, token_sot
int TranscriptionStart;
// Represents the previous word in the transcription. It is used to help the model predict t<|fim_suffix|>re it... | fim | Const-me/Whisper | c |
<|fim_suffix|> timestamps
Timestamps = 2,
// Create a new COM object for the results.
// Without this flag, the context returns a pointer to the COM object stored in the context.
// The content of that object is replaced every time you call iContext.getResults method
NewObject = 0x100,
};
inline eResultFl... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "../../ComLightLib/comLightCommon.h"
#include "iTranscribeResult.cl.h"
#include "SpecialTokens.h"
#include "loggerApi.h"
#include "sLanguageList.h"
#include "sLoadModelCallbacks.h"
#include "sModelSetup.h"
namespace Whisper
{
struct iModel;
struct iAudioBuffer;
struct iAudioRead... | fim | Const-me/Whisper | c |
#pragma once
#include "iTranscribeResult.h"
#include "SpecialTokens.h"
#include "loggerApi.h"
#include "sLanguageList.h"
#include "sLoadModelCallbacks.h"
#include "sModelSetup.h"
namespace Whisper
{
__interface iModel;
__interface iAudioBuffer;
__interface iAudioReader;
__interface iAudioCapture;
struct sCapture... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "../../ComLightLib/comLightCommon.h"
#include "MfStructs.h"
struct IMFSourceReader;
namespace Whisper
{
struct DECLSPEC_NOVTABLE iAudioBuffer : public ComLight::IUnknown
{
DEFINE_INTERFACE_ID( "{013583aa-c9eb-42bc-83db-633c2c317051}" );
virtual uint32_t COMLIGHTCALL countSam... | fim | Const-me/Whisper | c |
<|fim_suffix|>all openAudioFile( LPCTSTR path, bool stereo, iAudioReader** pp );
HRESULT __stdcall loadAudioFileData( const void* data, uint64_t size, bool stereo, iAudioReader** pp );
HRESULT __stdcall listCaptureDevices( pfnFoundCaptureDevices pfn, void* pv );
HRESULT __stdcall openCaptureDevice( LPCTSTR endpo... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "TranscribeStructs.h"
#include "../../ComLightLib/comLightCommon.h"
namespace W<|fim_suffix|>st = 0;
virtual const sToken* COMLIGHTCALL getTokens() const = 0;
};
}<|fim_middle|>hisper
{
struct iTranscribeResult : public ComLight::IUnknown
{
DEFINE_INTERFACE_ID( "{2871a73f-5ce... | fim | Const-me/Whisper | c |
<|fim_suffix|>1935e" ) ) iTranscribeResult : public IUnknown
{
HRESULT __stdcall getSize( sTranscribeLength& rdi ) const;
const sSegment* __stdcall getSegments() const;
const sToken* __stdcall getTokens() const;
};
}<|fim_prefix|>#pragma once
#include "TranscribeStructs.h"
namespace Whisper
<|fim_middle|>{
__... | fim | Const-me/Whisper | c |
<|fim_suffix|>he sink function; when consuming from C# you don't need that, pass IntPtr.Zero, delegates can capture things.
void* context = nullptr;
// Maximum log level to produce
eLogLevel level;
// Flags about the logger
eLoggerFlags flags = (eLoggerFlags)0;
};
}<|fim_prefix|>#pragma once
#include <stdint... | fim | Const-me/Whisper | c |
#pragma once
#include <stdint.h>
#include <assert.h>
namespace Whisper
{
// Available sampling strategies
enum struct eSamplingStrategy : int
{
// Always select the most probable token
Greedy,
// TODO: not implemented yet!
BeamSearch,
};
using pfnNewSegment = HRESULT( __cdecl* )( iContext* ctx, uint32_t... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include <stdint.h>
namespace Whisper
{
struct sLanguageEntry
{
uint32_t<|fim_suffix|> sLanguageList
{
uint32_t length;
const sLanguageEntry* pointer;
};
}<|fim_middle|> key;
int id;
const char* name;
};
struct<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
namespace Whisper
{
using pfnLoadProgress = HR<|fim_suffix|>)( void* pv ) noexcept;
struct sLoadModelCallbacks
{
pfnLoadProgress progress;
pfnCancel cancel;
void* pv;
};
}<|fim_middle|>ESULT( __stdcall* )( double val, void* pv ) noexcept;
// Return S_OK to continue, or S_FALSE t... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include <stdint.h>
namespace Whisper
{
enum struct eModelImplementation : uint32_t
{
// GPGPU implementation based <|fim_suffix|> 2,
// A reference implementation which uses the original GGML CPU-running code
// Not implemented in the published builds of the DLL. To enable, change ... | fim | Const-me/Whisper | c |
<|fim_suffix|>TranscribeResult.cl.h"<|fim_prefix|>#pragma o<|fim_middle|>nce
#include "iMediaFoundation.cl.h"
#include "iContext.cl.h"
#include "i<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_suffix|>xt.h"
#include "iTranscribeResult.h"<|fim_prefix|>#pragma once
#include "iMediaFound<|fim_middle|>ation.h"
#include "iConte<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_suffix|> if( nullptr != res )
{
sizeAllocated += cbCommit;
assert( sizeAllocated <= sizeVirtual );
void* const res = pointer + head;
head = newHead;
dbgMarkUninitializedMemory( res, cb );
return res;
}
const HRESULT hr = getLastHr();
logErrorHr( hr, u8"VirtualAllocator.allocate, Virtual... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ocator which allocates a large chunk of virtual memory, and maps new physical pages into that memory region as needed.
class VirtualAllocator : public iArenaAllocator
{
uint8_t* pointer = nullptr;
size_t head = 0;
size_t sizeAllocated = 0;
size_t sizeVirtual = 0;
void resetArena() noexcept ov... | fim | Const-me/Whisper | c |
<|fim_suffix|>ttnLn0, i.attn_ln_0_w, i.attn_ln_0_b );
ctx.add2( i.attnLn1, i.attn_ln_1_w, i.attn_ln_1_b );
ctx.add2( i.attnQuery, i.attn_q_w, i.attn_q_b );
ctx.add( i.attnKey, i.attn_k_w );
ctx.add2( i.attnValue, i.attn_v_w, i.attn_v_b );
ctx.add2( i.crossAttnLn0, i.cross_attn_ln_0_w, i.cross_attn_ln_0_b );
... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>v_w;
ggml_tensor* attn_v_b;
// decoder.blocks.*.cross_attn_ln
ggml_tensor* cross_attn_ln_0_w;
ggml_tensor* cross_attn_ln_0_b;
// decoder.blocks.*.cross_attn.out
ggml_tensor* cross_attn_ln_1_w;
ggml_tensor* cross_attn_ln_1_b;
// decoder.blocks.*.cross_attn.query
ggml_tensor* cross_attn... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "HybridLoader.h"
using namespace CpuCompute;
using namespace ComLight;
static void populateDecodeTensorsMap( CAtlMap<CStringA, Tensor*>& map, int layersDec, DecoderTensors& dec )
{
dec.layers.resize( layersDec );
map[ "decoder.positional_embedding" ] = &dec.positionalEmbed... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "DecoderTensors.h"
#include <atlstr.h>
#include <atlcoll.h>
#include "../../ComLightLib/streams.h"
namespace CpuCompute
{
__interface iLoaderProgressSink
{
HRESULT gotBytes( int64_t cb );
};
class HybridLoader
{
DecoderTen<|fim_suffix|> int ftype, const std::array<int, 4>&... | fim | Const-me/Whisper | c |
<|fim_suffix|>+ off <= size )
return Tensor::fromData( values + off, eDataType::FP16, len );
throw E_BOUNDS;
}
};
}<|fim_prefix|>#pragma once
#include "Tensor.h"
#include "LargeBuffer.h"
#include "../Whisper/sModelParams.h"
namespace CpuCompute
{
class KvTensors
{
uint16_t* keys = nullptr;
uint16_t* va... | fim | Const-me/Whisper | c |
<|fim_suffix|>const Whisper::sModelParams& mp )
{
const uint32_t n_mem = mp.n_text_layer * mp.n_text_ctx;
const uint32_t n_elements = mp.n_text_state * n_mem;
const size_t cb = sizeof( uint16_t ) * (size_t)n_elements * 2;
CHECK( memory.allocate( cb ) );
uint16_t* pointer = (uint16_t*)memory.pointer();
keys = po... | fim | Const-me/Whisper | cpp |
<|fim_suffix|> return HRESULT_FROM_WIN32( GetLastError() );
}
HRESULT LargeBuffer::setReadOnly( size_t cb )
{
if( nullptr != pv )
{
DWORD op = 0;
if( VirtualProtect( pv, cb, PAGE_READONLY, &op ) )
return S_OK;
return HRESULT_FROM_WIN32( GetLastError() );
}
else
return OLE_E_BLANK;
}<|fim_prefix|>#includ... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ed by memory page = 4 kilobytes
uint8_t* pointer() const
{
assert( nullptr != pv );
return (uint8_t*)pv;
}
};
}<|fim_prefix|>#pragma once
namespace CpuCompute
{
// A large memory buffer allocated with VirtualAlloc kernel API, bypassing the heap.
class LargeBuffer
{
void* pv = nullptr;
... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "Tensor.h"
#include "ParallelForRunner.h"
namespace CpuCompute
{
class MlContext
{
ParallelForRunner pfor;
iMemoryAllocator* allocator = nullptr;
public:
MlContext( int threads );
MlContext( const MlContext& ) = delete;
~MlContext() = default;
HRESULT setThreadsCoun... | fim | Const-me/Whisper | c |
<|fim_suffix|>xis0 != axis3 );
assert( axis1 != axis2 );
assert( axis1 != axis3 );
assert( axis2 != axis3 );
Tensor res = a;
res.ne[ axis0 ] = a.ne[ 0 ];
res.ne[ axis1 ] = a.ne[ 1 ];
res.ne[ axis2 ] = a.ne[ 2 ];
res.ne[ axis3 ] = a.ne[ 3 ];
res.nb[ axis0 ] = a.nb[ 0 ];
res.nb[ axis1 ] = a.nb[ 1 ];
res.nb[ ... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#include "stdafx.h"
#include "ParallelForRunner.h"
using namespace CpuCompute;
ParallelForRunner::ParallelForRunner( int threads ) :
maxThreads( threads )
{
if( maxThreads <= 1 )
{
threadBuffers.resize( 1 );
return;
}
work = CreateThreadpoolWork( &workCallbackStati<|fim_suffix|>cb )
{
// W... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>v, PTP_WORK Work ) noexcept;
};
}<|fim_prefix|>#pragma once
#include "LargeBuffer.h"
namespace CpuCompute
{
// Callback interface for the parallel `for`
__interface iComputeRange
{
// The implementation calls this method on multiple thread pool threads in parallel, and aggregates status codes.
HR... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include "../D3D/enums.h"
#include "../ML/TensorShape.h"
// 1 = new tensors can be allocated with `nullptr` iMemoryAllocator, by allocating memory internally and counting these references
// 0 = memory allocator is mandatory, create() methods will fail with E_POINTER if the allocator is `null... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include <stdafx.h>
#include <atomic>
#include "Tensor.h"
using namespace CpuCompute;
#if TENSOR_INTERNAL_ALLOC
namespace
{
// This structure is immediately before the payload of every tensor which has an internally-allocated memory buffer
class alignas( 32 ) sTensorMemoryHeader
{
std::atomic_ptrdif... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>mulMatImpl<2, 4>( result, a, b, pfor );
else
return mulMatImpl<1, 4>( result, a, b, pfor );
}
}<|fim_prefix|>#include "stdafx.h"
#include "mulMat.h"
#include "mulMatImpl.h"
using namespace CpuCompute;
namespace
{
template<uint8_t panelHeightRegs, uint8_t tileWidthFloats>
static HRESULT mulMatImp... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ULT mulMat( ggml_tensor* result, const ggml_tensor* a, const ggml_tensor* b, CpuCompute::ParallelForRunner& pfor )
{
CpuCompute::Tensor r{ result }, lhs{ a }, rhs{ b };
return CpuCompute::mulMat( r, lhs, rhs, pfor );
}
#endif<|fim_prefix|>#pragma once
#include "Parall<|fim_middle|>elForRunner.h"
#includ... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include <stdint.h>
#include <immintrin.h>
#include "simdUtils.h"
template<uint8_t panelHeightRegs, uint8_t tileWidthFloats>
struct ResultTile
{
static constexpr size_t totalRegs = (size_t)(tileWidthFloats)*panelHeightRegs;
std::array<__m256, totalRegs> ar<|fim_suffix|>2, 3>::kernel( const... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#include "stdafx.h"
#include "mulMatImpl.h"
#include <immintrin.h>
#include "mulMatUtils.hpp"
using namespace CpuCompute;
namespace
{
constexpr size_t prefetchBytes = 96;
constexpr int prefetchHint = _MM_HINT_T0;
constexpr size_t maskAlign16 = ~(size_t)15;
__forceinline __m256i load( const void* rs... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
// Matrix*matrix multiplication is the most expensive algorithm in the model, by far.
// For this reason, the code in this source file, and in the mulMat.kernel.hpp header, is optimized for performance. Readability suffers.
// The implementation is inspired by following two articles:
// https... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include <intrin.h>
#include "mulMatImpl.h"
#include "mulMatUtils.hpp"
using namespace CpuCompute;
// We want to keep code size reasonable, that's why these panel reshaping methods are in the base class
HRESULT MulMatBase::transposePanel( uint16_t* rdi, size_t i, size_t m2, size_t m3 ... | fim | Const-me/Whisper | cpp |
#pragma once
#include <immintrin.h>
#include <stdint.h>
#include <assert.h>
__forceinline __m128i f16Load( const uint16_t* rsi )
{
return _mm_loadu_si128( ( const __m128i* )rsi );
}
constexpr size_t maskAlign8 = ~(size_t)7;
__forceinline void transpose8( uint16_t* rdi, size_t w, const uint16_t* rsi, size_t sourceSt... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#include "stdafx.h"
#include "simdUtils.h"
#include "../ML/LookupTablesData.h"
#include <cmath>
#include <memory>
namespace
{
constexpr size_t maskAlign8 = ~(size_t)7;
__forceinline __m256 load8( const uint16_t* rsi )
{
__m128i i = _mm_loadu_si128( ( const __m128i* )rsi );
return _mm256_cvtph_ps(... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>InPlace( float* rdi, const float* rsi, size_t length );
void addRow( float* rdi, const float* a, const float* b, size_t length );<|fim_prefix|>#pragma once
#include <immintrin.h>
void addF16to32( float* rdi, const uint16_t* a, const uint16_t* b, size_t length );
void addF16to32( float* rdi, const uint16_... | fim | Const-me/Whisper | c |
<|fim_suffix|>xt()->CSSetUnorderedAccessViews( 0, 1, &uav0, nullptr );
maxUav = std::max( maxUav, (uint8_t)1 );
}
void Binder::bind( ID3D11ShaderResourceView* srv0, ID3D11ShaderResourceView* srv1, ID3D11UnorderedAccessView* uav0 )
{
ID3D11DeviceContext* const ctx = context();
ctx->CSSetUnorderedAccessViews( 0, 1, &... | fim | Const-me/Whisper | cpp |
<|fim_prefix|>#pragma once
#include "device.h"
namespace DirectCompute
{
class<|fim_suffix|> ~Binder();
};
}<|fim_middle|> Binder
{
uint8_t maxSrv = 0;
uint8_t maxUav = 0;
public:
Binder() = default;
Binder( const Binder& ) = delete;
void bind( ID3D11ShaderResourceView* srv0, ID3D11UnorderedAccessView*... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "MappedResource.h"
using namespace DirectCompute;
#define CHECK( hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; }
MappedResource::MappedResource()
{
mapped.pData = nullptr;
mapped.RowPitch = mapped.DepthPitch = 0;
resource = nullptr;
}
HRESULT Mappe... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>ED_SUBRESOURCE mapped;
ID3D11Resource* resource;
public:
MappedResource();
HRESULT map( ID3D11Resource* res, bool reading );
~MappedResource();
void* data() const
{
assert( nullptr != mapped.pData );
return mapped.pData;
}
};
}<|fim_prefix|>#pragma once
#include "device.h"
#inclu<|f... | fim | Const-me/Whisper | c |
<|fim_suffix|>= dev )
return;
api->StartFrameCapture( dev, nullptr );
capturing = true;
}
CaptureRaii::~CaptureRaii()
{
if( !capturing )
return;
api->EndFrameCapture( device(), nullptr );
}
#else // !ENABLE_RENDERDOC_DEBUGGER
bool DirectCompute::initializeRenderDoc()
{
return false;
}
DirectCompute::CaptureR... | fim | Const-me/Whisper | cpp |
#pragma once
namespace DirectCompute
{
bool initializeRenderDoc();
class CaptureRaii
{
bool capturing;
public:
CaptureRaii();
CaptureRaii( const CaptureRaii& ) = delete;
~CaptureRaii();
};
}<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_suffix|>onnectTargetControl is 1, the Replay UI will be launched with a command line parameter
// to connect to this application
// cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
// if cmdline is NULL, the command line will be empty.
//
// returns the PID of the replay UI if s... | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "createBuffer.h"
#define CHECK( hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; }
HRESULT DirectCompute::createBuffer( eBufferUse use, size_t totalBytes, ID3D11Buffer** ppGpuBuffer, const void* rsi, ID3D11Buffer** ppStagingBuffer, bool shared )
{
if( t... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>11Buffer** ppGpuBuffer, const void* rsi, ID3D11Buffer** ppStagingBuffer, bool shared = false );
}<|fim_prefix|>#pragma once
#include "en<|fim_middle|>ums.h"
#include "device.h"
namespace DirectCompute
{
HRESULT createBuffer( eBufferUse use, size_t totalBytes, ID3D<|endoftext|> | fim | Const-me/Whisper | c |
<|fim_prefix|>#include "stdafx.h"
#include "createDevice.h"
#include "listGPUs.h"
#include "RenderDoc/renderDoc.h"
#pragma comment(lib, "D3D11.lib")
#include <atlstr.h>
HRESULT DirectCompute::createDevice( const std::wstring& adapterName, ID3D11Device** dev, ID3D11DeviceContext** context )
{
CComPtr<IDXGIAdapter1> ad... | fim | Const-me/Whisper | cpp |
<|fim_suffix|>are GPU
HRESULT cloneDevice( ID3D11Device* source, ID3D11Device** dev, ID3D11DeviceContext** context );
}<|fim_prefix|>// Low-level functions to create and initialize D3D11 device
#pragma once
#include <string>
#include "sGpuInfo.h"
namespace DirectCompute
{
HRESULT createDevice( const std::wstring& ad... | fim | Const-me/Whisper | c |
<|fim_prefix|>#pragma once
#include <atlcomcli.h>
#include <string>
#include "sGpuInfo.h"
namespace DirectCompute
{
ID3D11Device* device();
ID3D11DeviceContext* cont<|fim_suffix|>ConstantBuffers( 0, 1, &cb );
}
__m128i bufferMemoryUsage( ID3D11Buffer* buffer );
__m128i resourceMemoryUsage( ID3D11ShaderResourceV... | fim | Const-me/Whisper | c |
<|fim_suffix|>b );
return bi.download( vec.data() );
}
template HRESULT DirectCompute::downloadBuffer( ID3D11ShaderResourceView* srv, std::vector<uint16_t>& vec );
template HRESULT DirectCompute::downloadBuffer( ID3D11ShaderResourceView* srv, std::vector<float>& vec );<|fim_prefix|>#include "stdafx.h"
#include "downl... | fim | Const-me/Whisper | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.