tensorShape_t¶
The tensorShape_t is used to describe the rank and dimensions of data and view objects. It can be initialized with initializer-list syntax to improve clarity.
-
template<int RANK>
class matx::tensorShape_t¶ Class containing the shape and type of a tensor.
tensorShape_t contains metadata about the shape of a tensor but does not contain any data.
Public Functions
-
inline tensorShape_t(const index_t *const sizes) noexcept¶
Constructor for a rank-1 and above tensor.
- Parameters
sizes – Sizes for each dimension. Length of sizes must match RANK
-
template<int M = RANK, std::enable_if_t<M != 0, bool> = true>
inline tensorShape_t(const index_t (&sizes)[M])¶ Constructor for a rank-1 and above tensor using initializer lists
- Parameters
sizes – Sizes for each dimension. Length of sizes must match RANK
-
template<typename T, std::enable_if_t<!std::is_array_v<typename remove_cvref<T>::type> && !std::is_pointer_v<typename remove_cvref<T>::type>, bool> = true>
inline tensorShape_t(const T &sizes)¶ Constructor for a rank-1 and above tensor using initializer lists
- Parameters
sizes – Sizes for each dimension. Length of sizes must match RANK
-
__MATX_HOST__ __MATX_DEVICE__ inline index_t Size([[maybe_unused]] uint32_t dim) const noexcept¶
Get the size of a single dimension of the tensor
- Parameters
dim – Desired dimension
- Returns
Number of elements in dimension
-
__MATX_HOST__ __MATX_DEVICE__ inline index_t TotalSize() const noexcept¶
Get the total size of the shape
- Returns
The size of all dimensions combined. Note that this does not include the size of the data type itself, but only the product of the lengths of each dimension
-
inline void SetSize(int dim, index_t size)¶
Set the size of a dimension
- Parameters
dim – Dimension to set
size – Set the size of a dimension
Public Static Functions
-
__MATX_HOST__ __MATX_DEVICE__ static inline constexpr int32_t Rank()¶
Get the rank of the tensor
- Returns
Rank of the tensor
-
inline tensorShape_t(const index_t *const sizes) noexcept¶