Class EngineSettings
public sealed class EngineSettings : LiteRTLMNativeHandle
- Inheritance
-
objectEngineSettings
- Inherited Members
Constructors
EngineSettings(int, string, string?, string?)
Creates managed engine settings from a raw file descriptor. The engine takes ownership of the file descriptor and closes it when done. The caller is responsible for disposing the wrapper using Dispose().
public EngineSettings(int fd, string backend, string? visionBackend = null, string? audioBackend = null)
Parameters
fdintThe file descriptor of the model.
backendstringThe backend to use (for example, "cpu" or "gpu").
visionBackendstringThe vision backend to use, or null if not set.
audioBackendstringThe audio backend to use, or null if not set.
Remarks
See BackendNames for valid backend strings.
Exceptions
- InvalidOperationException
Thrown if the native object could not be created.
EngineSettings(string, string, string?, string?)
Creates managed engine settings from a model path. The caller is responsible for disposing the wrapper using Dispose().
public EngineSettings(string modelPath, string backend, string? visionBackend = null, string? audioBackend = null)
Parameters
modelPathstringThe path to the model file.
backendstringThe backend to use (for example, "cpu" or "gpu").
visionBackendstringThe vision backend to use, or null if not set.
audioBackendstringThe audio backend to use, or null if not set.
Remarks
See BackendNames for valid backend strings.
Exceptions
- InvalidOperationException
Thrown if the native object could not be created.
Methods
EnableBenchmark()
Enables benchmarking for the engine.
public void EnableBenchmark()
ReleaseUnmanagedResources()
protected override void ReleaseUnmanagedResources()
SetActivationDataType(ActivationDataType)
Sets the activation data type.
public void SetActivationDataType(ActivationDataType activationDataType)
Parameters
activationDataTypeActivationDataTypeThe activation data type.
SetAudioLoraRank(int)
Sets the Audio LoRA rank for the engine.
public void SetAudioLoraRank(int loraRank)
Parameters
loraRankintThe Audio LoRA rank.
SetAudioNumThreads(int)
Sets the number of threads for the audio CPU backend.
public void SetAudioNumThreads(int numThreads)
Parameters
numThreadsintThe number of threads.
SetCacheDir(string)
Sets the cache directory for the engine.
public void SetCacheDir(string cacheDir)
Parameters
cacheDirstringThe cache directory.
SetEnableSpeculativeDecoding(bool)
Sets whether to enable speculative decoding.
public void SetEnableSpeculativeDecoding(bool enableSpeculativeDecoding)
Parameters
enableSpeculativeDecodingboolWhether to enable speculative decoding.
SetLitertDispatchLibDir(string)
Sets the LiteRT dispatch library directory for the NPU backend.
public void SetLitertDispatchLibDir(string libDir)
Parameters
libDirstringThe dispatch library directory.
SetLoraRank(int)
Sets the LoRA rank for the engine.
public void SetLoraRank(int loraRank)
Parameters
loraRankintThe LoRA rank.
SetMaxNumImages(int)
Sets the maximum number of images for the engine. This is only used for the legacy implementation of the engine.
public void SetMaxNumImages(int maxNumImages)
Parameters
maxNumImagesintThe maximum number of images.
SetMaxNumTokens(int)
Sets the maximum number of tokens for the engine.
public void SetMaxNumTokens(int maxNumTokens)
Parameters
maxNumTokensintThe maximum number of tokens.
SetNumDecodeTokens(int)
Sets the number of decode tokens for benchmarking.
public void SetNumDecodeTokens(int numDecodeTokens)
Parameters
numDecodeTokensintThe number of decode tokens.
SetNumPrefillTokens(int)
Sets the number of prefill tokens for benchmarking.
public void SetNumPrefillTokens(int numPrefillTokens)
Parameters
numPrefillTokensintThe number of prefill tokens.
SetNumThreads(int)
Sets the number of threads for the CPU backend.
public void SetNumThreads(int numThreads)
Parameters
numThreadsintThe number of threads.
SetParallelFileSectionLoading(bool)
Sets whether the engine should load different sections of the litertlm file in parallel. Defaults to true.
public void SetParallelFileSectionLoading(bool parallelFileSectionLoading)
Parameters
parallelFileSectionLoadingboolWhether to load in parallel.
SetPrefillChunkSize(int)
Sets the prefill chunk size for the engine. Only applicable for the CPU backend with dynamic models.
public void SetPrefillChunkSize(int prefillChunkSize)
Parameters
prefillChunkSizeintThe prefill chunk size.
SetSupportedAudioLoraRanks(int[])
Sets the supported Audio LoRA ranks for the engine.
public int SetSupportedAudioLoraRanks(int[] loraRanks)
Parameters
loraRanksint[]An array of supported Audio LoRA ranks.
Returns
- int
0 on success, non-zero on failure.
SetSupportedLoraRanks(int[])
Sets the supported LoRA ranks for the engine.
public int SetSupportedLoraRanks(int[] loraRanks)
Parameters
loraRanksint[]An array of supported LoRA ranks.
Returns
- int
0 on success, non-zero on failure.