asFloat32View method
Mutable Float32List view aliasing this tensor's native buffer.
Writes go directly into tensor memory with no copy; both indexed
stores and bulk Float32List.setAll/Float32List.setRange are
supported. The view is valid until the next
resizeInputTensor/allocateTensors call; recapture after either.
The bytes are reinterpreted as float32 regardless of the tensor's element type; for quantized tensors use data instead.
Implementation
Float32List asFloat32View() {
final byteSize = tfliteBinding.TfLiteTensorByteSize(_tensor);
if (byteSize % 4 != 0) {
throw ArgumentError('Tensor byte size $byteSize is not float32-aligned.');
}
final data = cast<Float>(tfliteBinding.TfLiteTensorData(_tensor));
checkState(isNotNull(data), message: 'Tensor data is null.');
return data.asTypedList(byteSize ~/ 4);
}