public final class RawTensor extends Object implements Tensor
A raw tensor is a minimalist representation of a tensor allocated in native memory by the
TensorFlow runtime library and it controls its lifetime within the current process. The data
is represented by a flat buffer of bytes
, until it is mapped in a
n-dimensional typed space by a typed tensor
.
Instances of a RawTensor are not thread-safe and their resource must be released
by calling close()
explicitly or implicitly via try-with-resources.
Modifier and Type | Method and Description |
---|---|
RawTensor |
asRawTensor()
Returns a raw (untyped) representation of this tensor
|
void |
close()
Release resources associated with the Tensor.
|
org.tensorflow.ndarray.buffer.ByteDataBuffer |
data()
Returns the raw data of this tensor as a buffer of bytes.
|
DataType |
dataType()
Returns the
DataType of elements stored in the tensor. |
long |
numBytes()
Returns the size, in bytes, of the tensor data.
|
org.tensorflow.ndarray.Shape |
shape()
Returns the shape of the tensor.
|
String |
toString()
Returns a string describing the type and shape of the tensor.
|
public DataType dataType()
Tensor
DataType
of elements stored in the tensor.public long numBytes()
Tensor
public org.tensorflow.ndarray.Shape shape()
Tensor
public RawTensor asRawTensor()
Tensor
asRawTensor
in interface Tensor
public void close()
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.
close
in interface AutoCloseable
close
in interface Tensor
public org.tensorflow.ndarray.buffer.ByteDataBuffer data()
IllegalStateException
- if the tensor has been closedCopyright © 2015–2022. All rights reserved.