Contents

specialize(contentsOf:options:cache:cachePolicy:)

Specializes a model for the current device.

Declaration

@discardableResult static func specialize(contentsOf modelURL: URL, options: SpecializationOptions = .default, cache: AIModelCache = .default, cachePolicy: AIModelCache.Policy = .default) async throws -> AIModel

Parameters

  • modelURL:

    The URL of a .aimodel or .aimodelc file.

  • options:

    Options for the specialization process.

  • cache:

    The cache to store the resulting specialized asset in.

  • cachePolicy:

    The policy to apply to the resulting specialized asset.

Mentioned in

Return Value

The model, ready for inference on the current device.

Discussion

This method performs specialization on the input .aimodel or .aimodelc, storing the resulting specialized assets in the specified cache.