Table of Contents

Class NativeAPI.ModelInfo

Namespace
Uralstech.UAI.LiteRTLM.Native
public static class NativeAPI.ModelInfo
Inheritance
object
NativeAPI.ModelInfo

Methods

litert_lm_loaded_file_create(string)

Loads a LiteRT-LM file from the given path for capability queries.

public static extern nint litert_lm_loaded_file_create(string litertlmPath)

Parameters

litertlmPath string

Returns

nint

Returns nint.Zero if the file cannot be opened.

litert_lm_loaded_file_delete(nint)

Deletes a loaded LiteRT-LM file.

public static extern void litert_lm_loaded_file_delete(nint loadedFile)

Parameters

loadedFile nint

litert_lm_loaded_file_embedding_dimension(nint)

Returns the output embedding dimension for the model.

public static extern int litert_lm_loaded_file_embedding_dimension(nint loadedFile)

Parameters

loadedFile nint

The loaded file handle.

Returns

int

The output embedding dimension, or -1 if not defined.

Remarks

Returns -1 if the model is not an embedding model or if the dimension is not defined.

litert_lm_loaded_file_embedding_signature_selection(nint, int[]?, int)

Returns the number of supported embedding signature sequence lengths.

public static extern int litert_lm_loaded_file_embedding_signature_selection(nint loadedFile, int[]? lengths, int maxSize)

Parameters

loadedFile nint

The loaded file handle.

lengths int[]

The array to receive sequence lengths, or null to query the count.

maxSize int

The maximum number of sequence lengths to write.

Returns

int

The number of sequence lengths written, or -1 if the model is not an embedding model.

Remarks

Writes up to maxSize lengths to the provided lengths array. If lengths is null, only returns the count. Returns -1 if the model is not an embedding model or if signature lengths are not defined.

litert_lm_loaded_file_has_speculative_decoding_support(nint)

Returns true if the loaded LiteRT-LM file supports speculative decoding.

public static extern bool litert_lm_loaded_file_has_speculative_decoding_support(nint loadedFile)

Parameters

loadedFile nint

Returns

bool

litert_lm_loaded_file_is_dynamic_context(nint)

Returns whether the model has dynamic context.

public static extern bool litert_lm_loaded_file_is_dynamic_context(nint loadedFile)

Parameters

loadedFile nint

The loaded file handle.

Returns

bool

true if the model has dynamic context, false otherwise.

Remarks

Dynamic context means the context size can be configured by the caller up to the maximum limit.

litert_lm_loaded_file_max_context_tokens(nint)

Returns the maximum supported context tokens for the loaded LiteRT-LM file.

public static extern uint litert_lm_loaded_file_max_context_tokens(nint loadedFile)

Parameters

loadedFile nint

Returns

uint

Returns 0 if not found or on error.

Remarks

  • If the model is static (litert_lm_loaded_file_is_dynamic_context is false), this is the fixed context size determined by the model graph.
  • If the model is dynamic (litert_lm_loaded_file_is_dynamic_context is true), this is the largest context size that can be set.

litert_lm_loaded_file_max_vision_token_budget(nint)

Returns the maximum vision token budget for the model.

public static extern int litert_lm_loaded_file_max_vision_token_budget(nint loadedFile)

Parameters

loadedFile nint

Returns

int

Remarks

Returns -1 if the model does not support vision or if the budget is not defined.

litert_lm_loaded_file_min_runtime_version(nint)

Returns the minimum LiteRT-LM runtime version required to run this model.

public static extern nint litert_lm_loaded_file_min_runtime_version(nint loadedFile)

Parameters

loadedFile nint

The loaded file handle.

Returns

nint

A pointer to the UTF-8 version string, or nint.Zero if not defined.

Remarks

The returned pointer is valid as long as the loaded file is valid. Returns nint.Zero if the version requirement is not defined.

litert_lm_loaded_file_modality_npu_brand(nint, Modality)

Returns the detected NPU brand of the model for a given modality, or Unknown if not NPU-compiled for this modality.

public static extern NpuBrand litert_lm_loaded_file_modality_npu_brand(nint loadedFile, Modality modality)

Parameters

loadedFile nint

The loaded file handle.

modality Modality

The modality to query.

Returns

NpuBrand

The detected NPU brand.

litert_lm_loaded_file_modality_soc_name(nint, Modality)

Returns the target SoC name for a given modality (e.g. "SM8750", "Tensor_G5"), or nint.Zero if not specified or not NPU-compiled.

public static extern nint litert_lm_loaded_file_modality_soc_name(nint loadedFile, Modality modality)

Parameters

loadedFile nint

The loaded file handle.

modality Modality

The modality to query.

Returns

nint

A pointer to the UTF-8 SoC name string, or nint.Zero if not specified or not NPU-compiled.

Remarks

The returned pointer is valid as long as the loaded file is valid.

litert_lm_loaded_file_modality_supported_backends(nint, Modality, BackendType[]?, int)

Returns the number of supported backends for a given modality, ordered by priority (first entry is the default/highest-priority backend).

public static extern int litert_lm_loaded_file_modality_supported_backends(nint loadedFile, Modality modality, BackendType[]? backends, int maxSize)

Parameters

loadedFile nint
modality Modality
backends BackendType[]
maxSize int

Returns

int

If backends is null, only returns the count of supported backends. Returns 0 if the modality is not supported.

Remarks

Writes up to maxSize backends to the provided backends array.

litert_lm_loaded_file_model_type(nint)

Returns the model type of the loaded LiteRT-LM file.

public static extern ModelType litert_lm_loaded_file_model_type(nint loadedFile)

Parameters

loadedFile nint

The loaded file handle.

Returns

ModelType

The model type.

litert_lm_loaded_file_sampler_temperature(nint)

Returns the default sampler temperature for the model.

public static extern float litert_lm_loaded_file_sampler_temperature(nint loadedFile)

Parameters

loadedFile nint

Returns

float

litert_lm_loaded_file_sampler_top_k(nint)

Returns the default sampler topK for the model.

public static extern int litert_lm_loaded_file_sampler_top_k(nint loadedFile)

Parameters

loadedFile nint

Returns

int

litert_lm_loaded_file_sampler_top_p(nint)

Returns the default sampler topP for the model.

public static extern float litert_lm_loaded_file_sampler_top_p(nint loadedFile)

Parameters

loadedFile nint

Returns

float

litert_lm_loaded_file_sampler_type(nint)

Returns the default sampler type for the model.

public static extern SamplerType litert_lm_loaded_file_sampler_type(nint loadedFile)

Parameters

loadedFile nint

Returns

SamplerType

litert_lm_loaded_file_supports_function_calling(nint)

Returns true if the model supports function calling / tool use. If the metadata is not explicitly set in the model, this returns false.

public static extern bool litert_lm_loaded_file_supports_function_calling(nint loadedFile)

Parameters

loadedFile nint

Returns

bool

litert_lm_loaded_file_supports_input_modality(nint, Modality)

Returns true if the input modality is supported.

public static extern bool litert_lm_loaded_file_supports_input_modality(nint loadedFile, Modality modality)

Parameters

loadedFile nint
modality Modality

Returns

bool

litert_lm_loaded_file_supports_thinking(nint)

Returns true if the model supports thinking / reasoning steps. If the metadata is not explicitly set in the model, this returns false.

public static extern bool litert_lm_loaded_file_supports_thinking(nint loadedFile)

Parameters

loadedFile nint

Returns

bool

litert_lm_loaded_file_vision_signature_selection(nint, int[]?, int)

Returns the number of supported vision token lengths.

public static extern int litert_lm_loaded_file_vision_signature_selection(nint loadedFile, int[]? lengths, int maxSize)

Parameters

loadedFile nint
lengths int[]
maxSize int

Returns

int

If lengths is null, only returns the count. Returns -1 if the model does not support vision.

Remarks

Writes up to maxSize lengths to the provided array.