@Namespace(value="tensorflow") @NoOffset public static class tensorflow.Tensor extends tensorflow.AbstractTensor
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator| Constructor and Description |
|---|
Tensor()
\brief Creates a 1-dimensional, 0-element float tensor.
|
Tensor(int type)
\brief Creates an empty Tensor of the given data type.
|
Tensor(int type,
tensorflow.TensorShape shape)
\brief Creates a Tensor of the given
type and shape. |
Tensor(int type,
tensorflow.TensorShape shape,
Pointer data) |
Tensor(int type,
tensorflow.TensorShape shape,
tensorflow.TensorBuffer buf)
\brief Move constructor.
|
Tensor(long size)
Native array allocator.
|
Tensor(Pointer p)
Pointer cast constructor.
|
Tensor(tensorflow.Allocator a,
int type,
tensorflow.TensorShape shape)
\brief Creates a tensor with the input
type and shape, using
the allocator a to allocate the underlying buffer. |
Tensor(tensorflow.Allocator a,
int type,
tensorflow.TensorShape shape,
tensorflow.AllocationAttributes allocation_attr)
\brief Creates a tensor with the input
type and shape, using
the allocator a and the specified "allocation_attr" to
allocate the underlying buffer. |
Tensor(tensorflow.Tensor other)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
AllocatedBytes() |
void |
AsProtoField(tensorflow.TensorProto proto)
\brief Fills in
proto with *this tensor's content. |
void |
AsProtoTensorContent(tensorflow.TensorProto proto) |
boolean |
CopyFrom(tensorflow.Tensor other,
tensorflow.TensorShape shape)
\brief Copy the other tensor into this tensor and reshape it.
|
BytePointer |
DebugString()
A human-readable summary of the tensor suitable for debugging.
|
long |
dim_size(int d)
Convenience accessor for the tensor shape.
|
int |
dims()
\brief Convenience accessor for the tensor shape.
|
int |
dtype()
Returns the data type.
|
void |
FillDescription(tensorflow.TensorDescription description)
Fill in the
TensorDescription proto with metadata about the
tensor that is useful for monitoring and debugging. |
boolean |
FromProto(tensorflow.Allocator a,
tensorflow.TensorProto other) |
boolean |
FromProto(tensorflow.TensorProto other)
\brief Parse
other and construct the tensor. |
boolean |
IsAligned()
Returns true iff this tensor is aligned.
|
boolean |
IsInitialized()
\brief If necessary, has this Tensor been initialized?
Zero-element Tensors are always considered initialized, even if they
have never been assigned to and do not have any memory allocated.
|
boolean |
IsSameSize(tensorflow.Tensor b) |
long |
NumElements()
Convenience accessor for the tensor shape.
|
tensorflow.Tensor |
position(long position) |
tensorflow.Tensor |
put(tensorflow.Tensor other)
Assign operator.
|
tensorflow.TensorShape |
shape()
Returns the shape of the tensor.
|
boolean |
SharesBufferWith(tensorflow.Tensor b) |
tensorflow.Tensor |
Slice(long dim0_start,
long dim0_limit)
\brief Slice this tensor along the 1st dimension.
|
tensorflow.Tensor |
SubSlice(long index)
\brief Select a subslice from this tensor along the 1st dimension.
|
BytePointer |
SummarizeValue(long max_entries) |
BytePointer |
SummarizeValue(long max_entries,
boolean print_v2)
Render the first
max_entries values in *this into a string. |
BytePointer |
tensor_data()
\brief Returns a
StringPiece mapping the current tensor's buffer. |
long |
TotalBytes()
Returns the estimated memory usage of this tensor.
|
void |
UnsafeCopyFromInternal(tensorflow.Tensor arg0,
int dtype,
tensorflow.TensorShape arg2)
Copy the other tensor into this tensor and reshape it and reinterpret the
buffer's datatype.
|
create, create, create, create, create, create, create, createBuffer, createBuffer, createIndexer, createIndexer, createStringArrayaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic Tensor(Pointer p)
Pointer.Pointer(Pointer).public Tensor(long size)
Pointer.position(long).public Tensor()
c++
Tensor(DT_FLOAT, TensorShape({}))
public Tensor(@Cast(value="tensorflow::DataType") int type, @Const @ByRef tensorflow.TensorShape shape)
type and shape. If
LogMemory::IsEnabled() the allocation is logged as coming from
an unknown kernel and step. Calling the Tensor constructor
directly from within an Op is deprecated: use the
OpKernelConstruction/OpKernelContext allocate_* methods to
allocate a new tensor, which record the kernel and step.
The underlying buffer is allocated using a CPUAllocator.public Tensor(tensorflow.Allocator a, @Cast(value="tensorflow::DataType") int type, @Const @ByRef tensorflow.TensorShape shape)
type and shape, using
the allocator a to allocate the underlying buffer. If
LogMemory::IsEnabled() the allocation is logged as coming from
an unknown kernel and step. Calling the Tensor constructor
directly from within an Op is deprecated: use the
OpKernelConstruction/OpKernelContext allocate_* methods to
allocate a new tensor, which record the kernel and step.
a must outlive the lifetime of this Tensor.public Tensor(tensorflow.Allocator a, @Cast(value="tensorflow::DataType") int type, @Const @ByRef tensorflow.TensorShape shape, @Const @ByRef tensorflow.AllocationAttributes allocation_attr)
type and shape, using
the allocator a and the specified "allocation_attr" to
allocate the underlying buffer. If the kernel and step are known
allocation_attr.allocation_will_be_logged should be set to true
and LogMemory::RecordTensorAllocation should be called after the
tensor is constructed. Calling the Tensor constructor directly
from within an Op is deprecated: use the
OpKernelConstruction/OpKernelContext allocate_* methods to
allocate a new tensor, which record the kernel and step.
a must outlive the lifetime of this Tensor.public Tensor(@Cast(value="tensorflow::DataType") int type)
public Tensor(@Const @ByRef tensorflow.Tensor other)
public Tensor(@Cast(value="tensorflow::DataType") int type, tensorflow.TensorShape shape, tensorflow.TensorBuffer buf)
public Tensor(@Cast(value="tensorflow::DataType") int type, tensorflow.TensorShape shape, Pointer data)
public tensorflow.Tensor position(long position)
@Cast(value="tensorflow::DataType") public int dtype()
dtype in class tensorflow.AbstractTensor@Const @ByRef public tensorflow.TensorShape shape()
public int dims()
TensorShape in tensor_shape.h.dims in class tensorflow.AbstractTensor@Cast(value="tensorflow::int64") public long dim_size(int d)
dim_size in class tensorflow.AbstractTensor@Cast(value="tensorflow::int64") public long NumElements()
NumElements in class tensorflow.AbstractTensor@Cast(value="bool") public boolean IsSameSize(@Const @ByRef tensorflow.Tensor b)
@Cast(value="bool") public boolean SharesBufferWith(@Const @ByRef tensorflow.Tensor b)
@Cast(value="bool") public boolean IsInitialized()
@Cast(value="size_t") public long TotalBytes()
TotalBytes in class tensorflow.AbstractTensor@ByRef @Name(value="operator =") public tensorflow.Tensor put(@Const @ByRef tensorflow.Tensor other)
@Cast(value="bool") public boolean CopyFrom(@Const @ByRef tensorflow.Tensor other, @Const @ByRef tensorflow.TensorShape shape)
true
iff other.shape() has the same number of elements of the given
shape.@ByVal public tensorflow.Tensor Slice(@Cast(value="tensorflow::int64") long dim0_start, @Cast(value="tensorflow::int64") long dim0_limit)
I.e., the returned tensor satisfies
returned[i, ...] == this[dim0_start + i, ...].
The returned tensor shares the underlying tensor buffer with this
tensor.
NOTE: The returned tensor may not satisfy the same alignment
requirement as this tensor depending on the shape. The caller
must check the returned tensor's alignment before calling certain
methods that have alignment requirement (e.g., flat(), tensor()).
NOTE: When fed with an N-dimensional tensor, this method returns a tensor
also with N dimensions. If you want to select a sub tensor, see SubSlice.
REQUIRES: dims() >= 1
REQUIRES: 0 <= dim0_start <= dim0_limit <= dim_size(0)
@ByVal public tensorflow.Tensor SubSlice(@Cast(value="tensorflow::int64") long index)
flat(), tensor()).
REQUIRES: dims() >= 1
REQUIRES: 0 <= dim0_start < dim_size(0)@Cast(value="bool") public boolean FromProto(@Const @ByRef tensorflow.TensorProto other)
other and construct the tensor.
Returns true iff the parsing succeeds. If the parsing fails,
the state of *this is unchanged.
@Cast(value="bool") public boolean FromProto(tensorflow.Allocator a, @Const @ByRef tensorflow.TensorProto other)
public void AsProtoField(tensorflow.TensorProto proto)
proto with *this tensor's content.
AsProtoField() fills in the repeated field for proto.dtype(), while
AsProtoTensorContent() encodes the content in proto.tensor_content()
in a compact form.public void AsProtoTensorContent(tensorflow.TensorProto proto)
@StdString public BytePointer SummarizeValue(@Cast(value="tensorflow::int64") long max_entries, @Cast(value="bool") boolean print_v2)
max_entries values in *this into a string.@StdString public BytePointer SummarizeValue(@Cast(value="tensorflow::int64") long max_entries)
@StdString public BytePointer DebugString()
public void FillDescription(tensorflow.TensorDescription description)
TensorDescription proto with metadata about the
tensor that is useful for monitoring and debugging.@tensorflow.StringPiece public BytePointer tensor_data()
StringPiece mapping the current tensor's buffer.
The returned StringPiece may point to memory location on devices
that the CPU cannot address directly.
NOTE: The underlying tensor buffer is refcounted, so the lifetime
of the contents mapped by the StringPiece matches the lifetime of
the buffer; callers should arrange to make sure the buffer does
not get destroyed while the StringPiece is still used.
REQUIRES: DataTypeCanUseMemcpy(dtype()).tensor_data in class tensorflow.AbstractTensorpublic void UnsafeCopyFromInternal(@Const @ByRef tensorflow.Tensor arg0, @Cast(value="tensorflow::DataType") int dtype, @Const @ByRef tensorflow.TensorShape arg2)
Copyright © 2019. All rights reserved.