TensorUtils class

Utility class for working with ExecuTorch tensors

These helpers build TensorData directly rather than going through ExecutorchManager.instance. Routing through the singleton would make them throw on any platform without a native manager — notably web, where package:executorch_flutter supplies the manager and this library's ExecutorchManager.instance resolves to a stub that throws. Nothing here needs a manager: the conversion is pure Dart.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculateElementCount(List<int> shape) int
Calculate the total number of elements in a tensor shape
createFloat32Tensor2D({required List<List<double>> data, String? name}) TensorData
Create a float32 tensor from a 2D list (commonly used for images)
createFloat32Tensor3D({required List<List<List<double>>> data, String? name}) TensorData
Create a float32 tensor from a 3D list (commonly used for RGB images)
createFloat32Tensor4D({required List<List<List<List<double>>>> data, String? name}) TensorData
Create a float32 tensor from a 4D list (commonly used for batched images)
extractFloat32Data(TensorData tensor) List<double>
Extract numeric data from a tensor
extractInt32Data(TensorData tensor) List<int>
Extract integer data from a tensor
formatShape(List<int> shape) String
Format tensor shape as a human-readable string