Interpreter.fromAddress constructor

Interpreter.fromAddress(
  1. int address, {
  2. bool allocated = true,
  3. bool deleted = false,
  4. bool hasActiveDelegate = false,
})

Creates interpreter from an address.

Typically used for passing interpreter between isolates. allocated defaults to true because fromAddress is typically called after tensors have already been allocated on the original interpreter. This avoids redundant (and potentially thread-unsafe) allocateTensors() calls when used across isolate boundaries.

Implementation

factory Interpreter.fromAddress(
  int address, {
  bool allocated = true,
  bool deleted = false,
  bool hasActiveDelegate = false,
}) {
  final interpreter = Pointer<TfLiteInterpreter>.fromAddress(address);
  return Interpreter._(
      interpreter,
      hasActiveDelegate: hasActiveDelegate,
      skipAllocate: allocated,
    )
    .._deleted = deleted
    .._allocated = allocated;
}