getSignatureRunner method
Returns a SignatureRunner for the signature identified by signatureKey.
The caller is responsible for calling SignatureRunner.close on the returned runner before this Interpreter is closed.
Throws ArgumentError if signatureKey is not found in the model.
Example, run a training step:
final trainRunner = interpreter.getSignatureRunner('train');
final lossBuffer = Float32List(1);
trainRunner.run({'x': imageData, 'y': labels}, {'loss': lossBuffer});
print('Loss: ${lossBuffer[0]}');
trainRunner.close();
Implementation
SignatureRunner getSignatureRunner(String signatureKey) {
final keyPtr = signatureKey.toNativeUtf8();
try {
final runner = tfliteBinding.TfLiteInterpreterGetSignatureRunner(
_interpreter,
keyPtr.cast(),
);
checkArgument(
isNotNull(runner),
message:
'Signature "$signatureKey" not found. '
'Available signatures: ${signatureKeys.join(', ')}',
);
return SignatureRunner(runner);
} finally {
calloc.free(keyPtr);
}
}