Melange
API ReferenceiOS

ZeticMLangeModel

API reference for general model inference on iOS.

This page reflects ZeticMLange iOS 1.9.0.

ZeticMLangeModel loads a general on-device model from the Melange registry and runs tensor inference on iOS.

Import

import ZeticMLange

Initializer

public init(
  personalKey: String,
  name: String,
  version: Int? = nil,
  modelMode: ModelMode = .RUN_AUTO,
  quantType: QuantType? = nil,
  cacheHandlingPolicy: ModelCacheHandlingPolicy = .REMOVE_OVERLAPPING,
  onDownload: ((Float) -> Void)? = nil
) async throws
ParameterTypeDefaultDescription
personalKeyString-Personal key for accessing the model.
nameString-Model name in account_name/project_name format.
versionInt?nilModel version. nil loads the latest version.
modelModeModelMode.RUN_AUTOBackend selection strategy.
quantTypeQuantType?nilOptional precision filter.
cacheHandlingPolicyModelCacheHandlingPolicy.REMOVE_OVERLAPPINGManaged artifact cache cleanup policy.
onDownload((Float) -> Void)?nilDownload progress callback from 0.0 to 1.0.
let model = try await ZeticMLangeModel(
  personalKey: PERSONAL_KEY,
  name: "account_name/project_name"
)

run(inputs:)

Runs inference with tensors matching the model input order.

public func run(inputs: [Tensor]) throws -> [Tensor]
ParameterTypeDescription
inputs[Tensor]Input tensors matching the model's expected shapes and data types.

Returns: output tensors in model output order.

let outputs = try model.run(inputs: [inputTensor])
let firstOutput = outputs[0]

Lifecycle

public private(set) var isClosed: Bool
public func close()

Call close() when the model is no longer needed.

model.close()

On this page