collectOutputTensorInfo function

Map<int, OutputTensorInfo> collectOutputTensorInfo(
  1. Interpreter itp
)

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

Implementation

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;
}