TType
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
TBfloat16,
TBool,
TFloat16,
TFloat32,
TFloat64,
TFloating,
TInt32,
TInt64,
TIntegral,
TNumber,
TString,
TUint8
| TBfloat16 |
Brain 16-bit float tensor type. |
| TBool |
Boolean tensor type. |
| TFloat16 |
IEEE-754 half-precision 16-bit float tensor type. |
| TFloat32 |
IEEE-754 single-precision 32-bit float tensor type. |
| TFloat64 |
IEEE-754 double-precision 64-bit float tensor type. |
| TFloating |
Common interface for all floating point tensors. |
| TInt32 |
32-bit signed integer tensor type. |
| TInt64 |
64-bit signed integer tensor type. |
| TIntegral |
Common interface for all integral numeric tensors. |
| TNumber |
Common interface for all numeric tensors. |
| TString |
String type. |
| TUint8 |
8-bit unsigned integer tensor type. |
|
Common interface for all typed tensors.
Typed tensors wrap a RawTensor by mapping their native memory
to a n-dimensional data space allowing direct I/O access from the JVM.
Subinterfaces of TType are propagated as a generic parameter to various entities of
TensorFlow to identify the type of the tensor they carry. For example, a
Operand<TFloat32> is an operand which outputs a 32-bit floating
point tensor. This parameter ensure type-compatibility between operands of a computation at
compile-time. For example:
Ops tf = Ops.create();
Constant<TFloat32> c1 = tf.array(2.0f, 3.0f, 2.0f);
Constant<TFloat32> c2 = tf.array(1.0f, 2.0f, 3.0f);
Constant<TInt32> c3 = tf.array(2, 3, 2);
tf.math.add(c1, c2); // OK
tf.math.add(c1, c3); // Compilation failure
Even if all typed tensors implements somehow NdArray
to provide access to their data, TType deliberately does not extend directly from this
interface, for the following reasons:
- Implementing
NdArray at this level could only expose boxed-type accessors, which
are less performant than their primitive equivalent, only exposed by subinterfaces of
NdArray (e.g. FloatNdArray).
TType would need to carry a new generic parameter for typing the NdArray,
which will increase the verbosity in the signature of any method accepting or returning
an instance of this interface, which is very common.
Therefore, enforcing the user to cast a reference of
TType in a concrete tensor type before
accessing its data guarantees better performance and improves readability.
Public Methods
|
abstract
void
|
close()
Release resources associated with the Tensor.
|
|
abstract
DataType
|
|
|
abstract
long
|
numBytes()
Returns the size, in bytes, of the tensor data.
|
|
abstract
Class<? extends TType>
|
type()
Returns the type of this tensor as a registered subclass of TType
|
Inherited Methods
From interface
org.tensorflow.Tensor
|
abstract
RawTensor
|
asRawTensor()
Returns a raw (untyped) representation of this tensor
|
|
abstract
void
|
close()
Release resources associated with the Tensor.
|
|
abstract
DataType
|
|
|
abstract
long
|
numBytes()
Returns the size, in bytes, of the tensor data.
|
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, long size, Consumer<T> dataInitializer)
Allocates a tensor of a given datatype, shape and size.
|
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape)
Allocates a tensor of a given datatype and shape.
|
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, long size)
Allocates a tensor of a given datatype, shape and size.
|
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, Consumer<T> dataInitializer)
Allocates and initialize a tensor of a given datatype and shape.
|
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, ByteDataBuffer rawData)
Creates a Tensor of any type from the raw data provided by the given buffer.
|
|
abstract
Shape
|
shape()
Returns the shape of the tensor.
|
From interface
java.lang.AutoCloseable
Public Methods
public
abstract
void
close
()
Release resources associated with the Tensor.
WARNING:This must be invoked for all tensors that were not been produced by an eager
operation or memory will be leaked.
The Tensor object is no longer usable after close returns.
public
abstract
DataType
dataType
()
Returns the DataType of elements stored in the tensor.
public
abstract
long
numBytes
()
Returns the size, in bytes, of the tensor data.
public
abstract
Class<? extends TType>
type
()
Returns the type of this tensor as a registered subclass of TType
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-11-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-11-29 UTC."],[],[]]