A class for representing the shape of a tensor.
More...
#include <tensor_shape.h>
|
| TensorShape () |
| Default constructor.
|
|
| TensorShape (std::initializer_list< int64_t > dims) |
| Constructor with an initializer list of integers.
|
|
| TensorShape (const std::vector< int64_t > &dims) |
| Constructor with a vector of integers.
|
|
| TensorShape (const TensorShape &other) |
| Copy constructor.
|
|
int64_t | dim_size (int dim) const |
| Get the size of a dimension in the tensor.
|
|
const std::vector< int64_t > & | dims () const |
| Get all dimension sizes in the tensor.
|
|
const std::vector< int64_t > & | strides () const |
|
unsigned int | ndim () const |
| Get the ndim of the tensor.
|
|
void | set_dim_size (int dim, int64_t size) |
| Modify the size of a dimension in the tensor.
|
|
void | add_dim (int64_t size) |
| Add a new dimension to the tensor.
|
|
void | remove_dim (int dim) |
| Remove a dimension from the tensor.
|
|
int64_t | NumElements () const |
| Returns the total number of elements in the shape.
|
|
bool | operator== (const TensorShape &other) const |
| Overload the == operator to compare two TensorShape objects.
|
|
bool | operator!= (const TensorShape &other) const |
| Overload the != operator to compare two TensorShape objects.
|
|
|
std::vector< int64_t > | get_strides_ (const std::vector< int64_t > &dim) |
| Compute the strides of the tensor.
|
|
|
std::vector< int64_t > | dims_ = {} |
|
std::vector< int64_t > | strides_ = {} |
|
A class for representing the shape of a tensor.
◆ TensorShape() [1/4]
container::TensorShape::TensorShape |
( |
| ) |
|
◆ TensorShape() [2/4]
container::TensorShape::TensorShape |
( |
std::initializer_list< int64_t > |
dims | ) |
|
Constructor with an initializer list of integers.
- Parameters
-
dims | An initializer list of integers representing the dimensions of the tensor. |
◆ TensorShape() [3/4]
container::TensorShape::TensorShape |
( |
const std::vector< int64_t > & |
dims | ) |
|
Constructor with a vector of integers.
- Parameters
-
dims | A vector of integers representing the dimensions of the tensor. |
◆ TensorShape() [4/4]
container::TensorShape::TensorShape |
( |
const TensorShape & |
other | ) |
|
Copy constructor.
- Parameters
-
◆ add_dim()
void container::TensorShape::add_dim |
( |
int64_t |
size | ) |
|
Add a new dimension to the tensor.
- Parameters
-
size | The size of the new dimension. |
◆ dim_size()
int64_t container::TensorShape::dim_size |
( |
int |
dim | ) |
const |
Get the size of a dimension in the tensor.
- Parameters
-
dim | The index of the dimension. |
- Returns
- The size of the specified dimension.
◆ dims()
const std::vector< int64_t > & container::TensorShape::dims |
( |
| ) |
const |
Get all dimension sizes in the tensor.
- Returns
- A const reference to the vector of dimension sizes.
◆ get_strides_()
std::vector< int64_t > container::TensorShape::get_strides_ |
( |
const std::vector< int64_t > & |
dim | ) |
|
|
private |
Compute the strides of the tensor.
◆ ndim()
unsigned int container::TensorShape::ndim |
( |
| ) |
const |
Get the ndim of the tensor.
- Returns
- The number of dimensions in the tensor.
◆ NumElements()
int64_t container::TensorShape::NumElements |
( |
| ) |
const |
Returns the total number of elements in the shape.
- Returns
- int64_t The number of elements.
◆ operator!=()
bool container::TensorShape::operator!= |
( |
const TensorShape & |
other | ) |
const |
Overload the != operator to compare two TensorShape objects.
- Parameters
-
- Returns
- True if the two objects have different dimensions, false otherwise.
◆ operator==()
bool container::TensorShape::operator== |
( |
const TensorShape & |
other | ) |
const |
Overload the == operator to compare two TensorShape objects.
- Parameters
-
- Returns
- True if the two objects have the same dimensions, false otherwise.
◆ remove_dim()
void container::TensorShape::remove_dim |
( |
int |
dim | ) |
|
Remove a dimension from the tensor.
- Parameters
-
dim | The index of the dimension to be removed. |
◆ set_dim_size()
void container::TensorShape::set_dim_size |
( |
int |
dim, |
|
|
int64_t |
size |
|
) |
| |
Modify the size of a dimension in the tensor.
- Parameters
-
dim | The index of the dimension to be modified. |
size | The new size of the dimension. |
◆ strides()
const std::vector< int64_t > & container::TensorShape::strides |
( |
| ) |
const |
◆ dims_
std::vector<int64_t> container::TensorShape::dims_ = {} |
|
private |
◆ strides_
std::vector<int64_t> container::TensorShape::strides_ = {} |
|
private |
The documentation for this class was generated from the following files:
- /home/runner/work/abacus-develop/abacus-develop/source/source_base/module_container/ATen/core/tensor_shape.h
- /home/runner/work/abacus-develop/abacus-develop/source/source_base/module_container/ATen/core/tensor_shape.cpp