Manages the dimensions of a Tensor and their sizes.
tensorflow::TensorShape::TensorShape(gtl::ArraySlice< int64 > dim_sizes)
- Construct a
TensorShape
from the provided sizes. REQUIRES:dim_sizes[i] >= 0
- Construct a
tensorflow::TensorShape::TensorShape(std::initializer_list< int64 > dim_sizes)
tensorflow::TensorShape::TensorShape(const TensorShapeProto &proto)
- REQUIRES:
IsValid(proto)
- REQUIRES:
tensorflow::TensorShape::TensorShape()
void tensorflow::TensorShape::Clear()
- Clear a tensor shape.
void tensorflow::TensorShape::AddDim(int64 size)
- Add a dimension to the end ("inner-most"). REQUIRES:
size >= 0
- Add a dimension to the end ("inner-most"). REQUIRES:
void tensorflow::TensorShape::AppendShape(const TensorShape &shape)
- Appends all the dimensions from
shape
.
- Appends all the dimensions from
void tensorflow::TensorShape::InsertDim(int d, int64 size)
- Insert a dimension somewhere in the
TensorShape
. REQUIRES:0 <= d <= dims()
REQUIRES:size >= 0
- Insert a dimension somewhere in the
void tensorflow::TensorShape::set_dim(int d, int64 size)
- Modifies the size of the dimension
d
to besize
REQUIRES:0 <= d < dims()
REQUIRES:size >= 0
- Modifies the size of the dimension
void tensorflow::TensorShape::RemoveDim(int d)
- Removes dimension
d
from theTensorShape
. REQUIRES:0 <= d < dims()
- Removes dimension
int tensorflow::TensorShape::dims() const
- Return the number of dimensions in the tensor.
int64 tensorflow::TensorShape::dim_size(int d) const
- Returns the number of elements in dimension
d
. REQUIRES:0 <= d < dims()
- Returns the number of elements in dimension
gtl::ArraySlice<int64> tensorflow::TensorShape::dim_sizes() const
- Returns sizes of all dimensions.
int64 tensorflow::TensorShape::num_elements() const
- Returns the number of elements in the tensor.
bool tensorflow::TensorShape::IsSameSize(const TensorShape &b) const
bool tensorflow::TensorShape::operator==(const TensorShape &b) const
void tensorflow::TensorShape::AsProto(TensorShapeProto *proto) const
- Fill
*proto
from*this
.
- Fill
Eigen::DSizes< Eigen::DenseIndex, NDIMS > tensorflow::TensorShape::AsEigenDSizes() const
- Fill
*dsizes
from*this
.
- Fill
Eigen::DSizes< Eigen::DenseIndex, NDIMS > tensorflow::TensorShape::AsEigenDSizesWithPadding() const
TensorShapeIter tensorflow::TensorShape::begin() const
- For iterating through the dimensions.
TensorShapeIter tensorflow::TensorShape::end() const
string tensorflow::TensorShape::DebugString() const
- For error messages.
string tensorflow::TensorShape::ShortDebugString() const
static bool tensorflow::TensorShape::IsValid(const TensorShapeProto &proto)
- Returns
true
iffproto
is a valid tensor shape.
- Returns
Construct a TensorShape
from the provided sizes. REQUIRES: dim_sizes[i] >= 0
REQUIRES: IsValid(proto)
Create a tensor shape with no dimensions and one element, which you can then call AddDim()
on.
Clear a tensor shape.
Add a dimension to the end ("inner-most"). REQUIRES: size >= 0
Appends all the dimensions from shape
.
Insert a dimension somewhere in the TensorShape
. REQUIRES: 0 <= d <= dims()
REQUIRES: size >= 0
Modifies the size of the dimension d
to be size
REQUIRES: 0 <= d < dims()
REQUIRES: size >= 0
Removes dimension d
from the TensorShape
. REQUIRES: 0 <= d < dims()
Return the number of dimensions in the tensor.
Returns the number of elements in dimension d
. REQUIRES: 0 <= d < dims()
Returns sizes of all dimensions.
Returns the number of elements in the tensor.
We use int64
and not size_t
to be compatible with Eigen::Tensor
which uses ptrdiff_t
.
Returns true if *this
and b
have the same sizes. Ignores dimension names.
Fill *proto
from *this
.
Fill *dsizes
from *this
.
Same as AsEigenDSizes()
but allows for NDIMS > dims()
in which case we pad the rest of the sizes with 1.
For iterating through the dimensions.
For error messages.
Returns true
iff proto
is a valid tensor shape.