Tensor class
Multi-dimensional tensor backed by a contiguous Float32List buffer and stride calculations.
Constructors
-
Tensor(List<
int> shape) -
Creates a zero-initialized Tensor with the given
shape. -
Tensor.fromFloat32List(List<
int> shape, Float32List data) - Creates a Tensor wrapping a flat Float32List buffer.
Properties
- data → Float32List
-
Contiguous 32-bit floating point data buffer.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shape
→ List<
int> -
Dimension sizes of the tensor (e.g.
Channels, Height, WidthorBatch, Channels, Height, Width).final - size → int
-
Total number of elements in the tensor.
final
-
strides
→ List<
int> -
Stride offsets for each dimension.
final
Methods
-
clone(
) → Tensor - Creates a deep copy of this tensor.
-
get(
List< int> indices) → double -
Returns the value at multi-dimensional
indices. -
get3D(
int c, int h, int w) → double -
Fast accessor for 3D tensor:
[c, h, w]. -
get4D(
int b, int c, int h, int w) → double -
Fast accessor for 4D tensor:
[b, c, h, w]. -
getFlatIndex(
List< int> indices) → int -
Computes flat 1D buffer index from multi-dimensional
indices. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reshape(
List< int> newShape) → Tensor -
Returns a new Tensor sharing the same data buffer with a new
newShape. -
set(
List< int> indices, double value) → void -
Sets the value at multi-dimensional
indices. -
set3D(
int c, int h, int w, double val) → void -
Fast setter for 3D tensor:
[c, h, w]. -
set4D(
int b, int c, int h, int w, double val) → void -
Fast setter for 4D tensor:
[b, c, h, w]. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited