CompiledModel

class CompiledModel : JniHandle

Class that represents a compiled LiteRT model.

Summary

Nested types

Options to specify CPU acceleration for compiling a model.

Options to specify GPU acceleration for compiling a model.

Backend for GPU options.

Buffer storage type for GPU options.

Precision for GPU options.

Priority for GPU options.

Options to specify hardware acceleration for compiling a model.

Options to specify Qualcomm options for compiling a model.

HTP performance mode for Qualcomm options.

Log level for Qualcomm options.

Optimization level for Qualcomm options.

Profiling for Qualcomm options.

Public companion functions

CompiledModel
create(
    filePath: String,
    options: CompiledModel.Options,
    optionalEnv: Environment?
)
CompiledModel
create(
    assetManager: AssetManager,
    assetName: String,
    options: CompiledModel.Options,
    optionalEnv: Environment?
)

Public functions

TensorBuffer
createInputBuffer(inputName: String, signature: String)
List<TensorBuffer>
createInputBuffers(signatureIndex: Int)
List<TensorBuffer>
TensorBuffer
createOutputBuffer(outputName: String, signature: String)
List<TensorBuffer>
createOutputBuffers(signatureIndex: Int)
List<TensorBuffer>
TensorBufferRequirements
getInputBufferRequirements(inputName: String, signature: String)
TensorType
getInputTensorType(inputName: String, signature: String)
TensorBufferRequirements
getOutputBufferRequirements(outputName: String, signature: String)
TensorType
getOutputTensorType(outputName: String, signature: String)
List<TensorBuffer>
run(inputs: List<TensorBuffer>, signatureIndex: Int)
List<TensorBuffer>
run(inputs: List<TensorBuffer>, signature: String)
Unit
run(
    inputs: List<TensorBuffer>,
    outputs: List<TensorBuffer>,
    signatureIndex: Int
)
Unit
run(
    inputs: List<TensorBuffer>,
    outputs: List<TensorBuffer>,
    signature: String
)
Unit
run(
    inputs: Map<StringTensorBuffer>,
    outputs: Map<StringTensorBuffer>,
    signature: String
)

Protected functions

open Unit

Clean up resources associated with the handle.

Inherited functions

From com.google.ai.edge.litert.JniHandle
Unit

Asserts that the handle is not destroyed, otherwise throws an IllegalStateException.

final Unit

Clean up the handle safely to avoid releasing the same JNI handle multiple times.

Public companion functions

create

fun create(
    filePath: String,
    options: CompiledModel.Options = Options.CPU,
    optionalEnv: Environment? = null
): CompiledModel

create

fun create(
    assetManager: AssetManager,
    assetName: String,
    options: CompiledModel.Options = Options.CPU,
    optionalEnv: Environment? = null
): CompiledModel

Public functions

createInputBuffer

fun createInputBuffer(inputName: String, signature: String = ""): TensorBuffer

createInputBuffers

fun createInputBuffers(signatureIndex: Int = 0): List<TensorBuffer>

createInputBuffers

fun createInputBuffers(signature: String): List<TensorBuffer>

createOutputBuffer

fun createOutputBuffer(outputName: String, signature: String = ""): TensorBuffer

createOutputBuffers

fun createOutputBuffers(signatureIndex: Int = 0): List<TensorBuffer>

createOutputBuffers

fun createOutputBuffers(signature: String): List<TensorBuffer>

getInputBufferRequirements

fun getInputBufferRequirements(inputName: String, signature: String = ""): TensorBufferRequirements

getInputTensorType

fun getInputTensorType(inputName: String, signature: String = ""): TensorType

getOutputBufferRequirements

fun getOutputBufferRequirements(outputName: String, signature: String = ""): TensorBufferRequirements

getOutputTensorType

fun getOutputTensorType(outputName: String, signature: String = ""): TensorType

run

fun run(inputs: List<TensorBuffer>, signatureIndex: Int = 0): List<TensorBuffer>

run

fun run(inputs: List<TensorBuffer>, signature: String): List<TensorBuffer>

run

fun run(
    inputs: List<TensorBuffer>,
    outputs: List<TensorBuffer>,
    signatureIndex: Int = 0
): Unit

run

fun run(
    inputs: List<TensorBuffer>,
    outputs: List<TensorBuffer>,
    signature: String
): Unit

run

fun run(
    inputs: Map<StringTensorBuffer>,
    outputs: Map<StringTensorBuffer>,
    signature: String = ""
): Unit

Protected functions

destroy

protected open fun destroy(): Unit

Clean up resources associated with the handle.