import { Tensor } from '../tensor.ts'; import { type TqdmOnProgress } from '../helpers/tqdm.ts'; export declare const inverse_safe_dtypes: Map; /** * Loads a .safetensor file from disk, returning the data, metadata length, && metadata. */ export declare const safe_load_metadata: (t: Tensor | string) => Promise<[Tensor, number, Record]>; /** * Loads a .safetensor file from disk, returning the state_dict. * * ```python * state_dict = nn.state.safe_load("test.safetensor") * ``` */ export declare const safe_load: (fn: string | Tensor, target_device?: string) => Promise>; /** * Saves a state_dict to disk in a .safetensor file with optional metadata. * * ```python * t = Tensor([1, 2, 3]) * nn.state.safe_save({'t':t}, "test.safetensor") * ``` */ export declare const safe_save: (tensors: Record, fn: string, metadata?: Record) => Promise; /** * Returns a state_dict of the object, with optional prefix. * * ```python exec="true" source="above" session="tensor" result="python" * class Net { * const __init__ = () => { * this.l1 = nn.Linear(4, 5) * this.l2 = nn.Linear(5, 6) * * net = Net() * console.log(nn.state.get_state_dict(net).keys()) * ``` */ export declare const get_state_dict: (obj: any, prefix?: string) => Record; /** * ```python exec="true" source="above" session="tensor" result="python" * class Net: * const __init__ = () => { * this.l1 = nn.Linear(4, 5) * this.l2 = nn.Linear(5, 6) * * net = Net() * console.log(len(nn.state.get_parameters(net))) * ``` */ export declare const get_parameters: (obj: any) => Tensor[]; export declare const replace_state_dict: (state: Record, replace: Record, strict?: boolean) => Record; /** * Loads a state_dict into a model. * * ```python * class Net: * const __init__ = () => { * this.l1 = nn.Linear(4, 5) * this.l2 = nn.Linear(5, 6) * * net = Net() * state_dict = nn.state.get_state_dict(net) * nn.state.load_state_dict(net, state_dict) * ``` */ export declare const load_state_dict: (model: any, state_dict: Record, strict?: boolean, verbose?: boolean, consume?: boolean, onProgress?: TqdmOnProgress) => Promise; export declare const tar_extract: (t: Tensor) => Record; /** * Converts ggml tensor data to a tinygrad tensor. * * Supported native types: float32 (id: 0), float16 (id: 1), int8 (id: 16), int16 (id: 17), int32 (id: 18) * Supported quantized types: Q4_0 (id: 2), Q4_1 (id: 3), Q8_0 (id: 8), Q6_K (id: 14) */ export declare const ggml_data_to_tensor: (t: Uint8Array, n: number, ggml_type: number) => Tensor; /** * Loads a gguf file from a tensor. * * ```python * fn = "Meta-Llama-3-8B-Instruct.Q4_0.gguf" * gguf_tensor = Tensor.empty(os.stat(fn).st_size, dtype=dtypes.uint8, device=f"disk:{fn}").to(Device.DEFAULT) * kv_data, state_dict = gguf_load(gguf_tensor) * ``` */ export declare const gguf_load: (data: Uint8Array, onProgress?: TqdmOnProgress) => Promise<[Record, Record]>;