resizeInputTensor method

void resizeInputTensor(
  1. String name,
  2. List<int> shape
)

Resizes the input tensor identified by name to shape.

allocateTensors must be called again after any resize before invoking.

Implementation

void resizeInputTensor(String name, List<int> shape) {
  final namePtr = name.toNativeUtf8();
  try {
    final dimensionSize = shape.length;
    final dimensions = calloc<Int>(dimensionSize);
    try {
      final externalTypedData = dimensions.cast<Int32>().asTypedList(
        dimensionSize,
      );
      externalTypedData.setRange(0, dimensionSize, shape);
      final status = tfliteBinding.TfLiteSignatureRunnerResizeInputTensor(
        _runner,
        namePtr.cast(),
        dimensions,
        dimensionSize,
      );
      checkState(status == TfLiteStatus.kTfLiteOk);
      _allocated = false;
      _invalidateTensorCaches();
    } finally {
      calloc.free(dimensions);
    }
  } finally {
    calloc.free(namePtr);
  }
}