collectOutputTensorInfo function

  1. @Deprecated('Use collectOutputShapes from flutter_litert. Every call site here only read ' 'the shapes, and collectOutputShapes avoids touching Tensor.data. Will be ' 'removed in 7.0.0.')
Map<int, OutputTensorInfo> collectOutputTensorInfo(
  1. Interpreter itp
)

Collects output tensor shapes (and their backing buffers) for an interpreter.

Iterates output indices until getOutputTensor throws, mirroring existing try/break loops in model constructors.

Implementation

@Deprecated(
  'Use collectOutputShapes from flutter_litert. Every call site here only read '
  'the shapes, and collectOutputShapes avoids touching Tensor.data. Will be '
  'removed in 7.0.0.',
)
Map<int, OutputTensorInfo> collectOutputTensorInfo(Interpreter itp) {
  final Map<int, OutputTensorInfo> outputs = <int, OutputTensorInfo>{};
  for (int i = 0; ; i++) {
    try {
      final Tensor t = itp.getOutputTensor(i);
      outputs[i] = OutputTensorInfo(t.shape, t.data.buffer.asFloat32List());
    } catch (_) {
      break;
    }
  }
  return outputs;
}