Class TensorShape
Defined in File TensorShape.hpp
Class Documentation
-
class TensorShape
The TensorShape class represents the shape and layout of a tensor.
Public Functions
-
TensorShape() = default
Default constructor.
-
inline TensorShape(ShapeType shape, TensorLayout layout)
Constructs a TensorShape with the given shape and layout.
- Parameters:
shape – Shape of the tensor.
layout – Layout of the tensor.
-
inline TensorShape(int size, TensorLayout layout)
Constructs a TensorShape with the given size and layout.
- Parameters:
size – Size of the tensor.
layout – Layout of the tensor.
-
inline explicit TensorShape(TensorLayout layout)
Constructs a TensorShape with the given layout.
- Parameters:
layout – Layout of the tensor.
-
inline TensorShape(const DimType *data, int32_t size, TensorLayout layout)
Constructs a TensorShape with the given data, size, and layout.
- Parameters:
data – Pointer to the array of tensor dimensions.
size – Size of the tensor.
layout – Layout of the tensor.
-
inline TensorShape(const DimType *data, int32_t size, const char *layout)
Constructs a TensorShape with the given data, size, and layout.
- Parameters:
data – Pointer to the array of tensor dimensions.
size – Size of the tensor.
layout – Layout string of the tensor.
-
inline TensorShape(ShapeType shape, const char *layout)
Constructs a TensorShape with the given shape and layout.
- Parameters:
shape – Shape of the tensor.
layout – Layout string of the tensor.
-
inline const ShapeType &shape() const
Returns the shape of the tensor.
- Returns:
The shape of the tensor.
-
inline const TensorLayout &layout() const
Returns the layout of the tensor.
- Returns:
The layout of the tensor.
-
inline const DimType &operator[](int i) const
Returns the dimension size at the given index.
- Parameters:
i – Index of the dimension to return.
- Returns:
The dimension size at the given index.
-
inline int rank() const
Returns the rank (number of dimensions) of the tensor.
- Returns:
The rank of the tensor.
-
inline int size() const
Returns the size (total number of elements) of the tensor.
- Returns:
The size of the tensor.
-
inline bool empty() const
Checks if the tensor is empty.
- Returns:
True if the tensor is empty, false otherwise.
-
inline bool operator==(const TensorShape &that) const
Equality operator.
- Parameters:
that – The TensorShape to compare with.
- Returns:
True if this TensorShape is equal to
that
, false otherwise.
-
inline bool operator!=(const TensorShape &that) const
Inequality operator.
- Parameters:
that – The TensorShape to compare with.
- Returns:
True if this TensorShape is not equal to
that
, false otherwise.
-
inline bool operator<(const TensorShape &that) const
Less than operator.
- Parameters:
that – The TensorShape to compare with.
- Returns:
True if this TensorShape is less than
that
, false otherwise.
Friends
-
inline friend std::ostream &operator<<(std::ostream &out, const TensorShape &ts)
Overload of the << operator for pretty printing.
- Parameters:
out – The output stream.
ts – The TensorShape to print.
- Returns:
The output stream.
-
TensorShape() = default