tensorflow::PartialTensorShape

#include <partial_tensor_shape.h>

Manages the partially known dimensions of a Tensor and their sizes.

Summary

Constructors and Destructors

PartialTensorShape()
Construct an unknown PartialTensorShape.
PartialTensorShape(gtl::ArraySlice< int64 > dim_sizes)
Construct a PartialTensorShape from the provided sizes.
PartialTensorShape(std::initializer_list< int64 > dim_sizes)
PartialTensorShape(const TensorShapeProto & proto)
REQUIRES: IsValid(proto)

Public functions

AsProto(TensorShapeProto *proto) const
void
Fill *proto from *this.
AsTensorShape(TensorShape *tensor_shape) const
bool
Concatenate(int64 size) const
Add a dimension to the end ("inner-most"), returns a new PartialTensorShape.
Concatenate(const PartialTensorShape & shape) const
Appends all the dimensions from shape.
DebugString() const
string
For error messages.
IsCompatibleWith(const PartialTensorShape & shape) const
bool
Return true iff the ranks match, and if the dimensions all either match or one is unknown.
IsCompatibleWith(const TensorShape & shape) const
bool
Return true iff the dimensions of shape are compatible with *this.
IsFullyDefined() const
bool
Return true iff the rank and all of the dimensions are well defined.
MergeWith(const PartialTensorShape & shape, PartialTensorShape *result) const
Merges all the dimensions from shape.
dim_size(int d) const
int64
Returns the number of elements in dimension d.
dim_sizes() const
gtl::ArraySlice< int64 >
Returns sizes of all dimensions.
dims() const
int
Return the number of dimensions in the tensor.

Public static functions

DebugString(const TensorShapeProto & proto)
string
IsValid(const TensorShapeProto & proto)
bool
Returns true iff proto is a valid partial tensor shape.
IsValidShape(const TensorShapeProto & proto)
Returns OK iff proto is a valid tensor shape, and a descriptive error status otherwise.
MakePartialShape(const int32 *dims, int n, PartialTensorShape *out)
Returns a PartialTensorShape whose dimensions are dims[0], dims[1], ..., dims[n-1].
MakePartialShape(const int64 *dims, int n, PartialTensorShape *out)

Public functions

AsProto

void AsProto(
  TensorShapeProto *proto
) const 

Fill *proto from *this.

AsTensorShape

bool AsTensorShape(
  TensorShape *tensor_shape
) const 

Concatenate

PartialTensorShape Concatenate(
  int64 size
) const 

Add a dimension to the end ("inner-most"), returns a new PartialTensorShape.

REQUIRES: size >= -1, where -1 means unknown

Concatenate

PartialTensorShape Concatenate(
  const PartialTensorShape & shape
) const 

Appends all the dimensions from shape.

Returns a new PartialTensorShape.

DebugString

string DebugString() const 

For error messages.

IsCompatibleWith

bool IsCompatibleWith(
  const PartialTensorShape & shape
) const 

Return true iff the ranks match, and if the dimensions all either match or one is unknown.

IsCompatibleWith

bool IsCompatibleWith(
  const TensorShape & shape
) const 

Return true iff the dimensions of shape are compatible with *this.

IsFullyDefined

bool IsFullyDefined() const 

Return true iff the rank and all of the dimensions are well defined.

MergeWith

Status MergeWith(
  const PartialTensorShape & shape,
  PartialTensorShape *result
) const 

Merges all the dimensions from shape.

Returns InvalidArgument error if either shape has a different rank or if any of the dimensions are incompatible.

PartialTensorShape

 PartialTensorShape()

Construct an unknown PartialTensorShape.

PartialTensorShape

 PartialTensorShape(
  gtl::ArraySlice< int64 > dim_sizes
)

Construct a PartialTensorShape from the provided sizes.

REQUIRES: dim_sizes[i] >= 0

PartialTensorShape

 PartialTensorShape(
  std::initializer_list< int64 > dim_sizes
)

PartialTensorShape

 PartialTensorShape(
  const TensorShapeProto & proto
)

REQUIRES: IsValid(proto)

dim_size

int64 dim_size(
  int d
) const 

Returns the number of elements in dimension d.

REQUIRES: 0 <= d < dims()

dim_sizes

gtl::ArraySlice< int64 > dim_sizes() const 

Returns sizes of all dimensions.

dims

int dims() const 

Return the number of dimensions in the tensor.

If the number of dimensions is unknown, return -1.

Public static functions

DebugString

string DebugString(
  const TensorShapeProto & proto
)

IsValid

bool IsValid(
  const TensorShapeProto & proto
)

Returns true iff proto is a valid partial tensor shape.

IsValidShape

Status IsValidShape(
  const TensorShapeProto & proto
)

Returns OK iff proto is a valid tensor shape, and a descriptive error status otherwise.

MakePartialShape

Status MakePartialShape(
  const int32 *dims,
  int n,
  PartialTensorShape *out
)

Returns a PartialTensorShape whose dimensions are dims[0], dims[1], ..., dims[n-1].

Values of -1 are considered "unknown".

MakePartialShape

Status MakePartialShape(
  const int64 *dims,
  int n,
  PartialTensorShape *out
)