TensorBuffer class abstract
Represents the data buffer for either a model's input or its output.
- Implementers
Constructors
-
TensorBuffer(List<
int> shape) -
Constructs a fixed size TensorBuffer with specified
shape
. - TensorBuffer.dynamic()
- Constructs a dynamic TensorBuffer which can be resized.
Properties
- buffer → ByteBuffer
-
Returns the data buffer.
no setter
- byteData ↔ ByteData
-
Where the data is stored
getter/setter pair
- endian → Endian
-
final
- flatSize ↔ int
-
Number of elements in the buffer. It will be changed to a proper value in the constructor.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDynamic → bool
-
Returns if the TensorBuffer is dynamic sized (could resize arbitrarily).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shape
↔ List<
int> -
Shape of the tensor
getter/setter pair
Methods
-
getBuffer(
) → ByteBuffer - Returns the data buffer.
-
getDataType(
) → TfLiteType - Returns the data type of this buffer.
-
getDoubleList(
) → List< double> - Returns a List
-
getDoubleValue(
int absIndex) → double -
Returns a double value at
absIndex
. If the buffer is of different types than double, the value will be converted into double. For example, when reading a value from TensorBufferUint8, the value will be first read out as uint8, and then will be converted from uint8 to double. -
getFlatSize(
) → int - Gets the TensorBuffer.flatSize of the buffer.
-
getIntList(
) → List< int> - Returns an int array of the values stored in this buffer. If the buffer is of different type than int, the values will be converted into int, and loss of precision may apply. For example, getting an int array from a TensorBufferFloat with values {400.32, 23.04}, the output is {400, 23}.
-
getIntValue(
int absIndex) → int -
Returns an int value at
absIndex
. -
getShape(
) → List< int> - Gets the current shape. (returning a copy here to avoid unexpected modification.)
-
getTypeSize(
) → int - Returns the number of bytes of a single element in the list. For example, a float buffer will return 4, and a byte buffer will return 1.
-
loadBuffer(
ByteBuffer buffer, {List< int> ? shape}) → void -
Loads a byte buffer into this TensorBuffer with specific
shape
. -
loadList(
List src, {required List< int> shape}) → void - Loads an List
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resize(
List< int> shape) → void -
For dynamic buffer, resize the memory if needed. For fixed-size buffer, check if the
shape
of src fits the buffer size. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
computeFlatSize(
List< int> shape) → int - Calculates number of elements in the buffer.
-
createDynamic(
TfLiteType dataType) → TensorBuffer -
Creates an empty dynamic TensorBuffer with specified
TfLiteType
. The shape of the created TensorBuffer is {0}. -
createFixedSize(
List< int> shape, TfLiteType dataType) → TensorBuffer -
Creates a TensorBuffer with specified
shape
andTfLiteType
. Here are some examples: -
createFrom(
TensorBuffer buffer, TfLiteType dataType) → TensorBuffer -
Creates a TensorBuffer deep-copying data from another, with specified
TfLiteType
.