Class Shape
Constructor and Destructor
Description
Constructs or destructs an object of class Shape.
Prototype
Shape();
~Shape();
explicit Shape(const std::vector<int64_t>& dims)
Parameters
Parameter |
Input/Output |
Description |
---|---|---|
dims |
Input |
Value of Shape. Shape indicates the dimensions of a tensor. std::vector<int64_t> indicates each dimension. |
Returns
An Shape object.
Exception Handling
None
Restrictions
None
GetDim
Description
Obtains the size of dimension idx of Shape.
Prototype
int64_t GetDim(size_t idx) const
Parameters
Parameter |
Input/Output |
Description |
---|---|---|
idx |
Input |
Dimension index, starting at 0. |
Returns
Parameter |
Type |
Description |
---|---|---|
- |
int64_t |
Size of dimension idx. |
Exception Handling
None
Restrictions
None
GetDims
Description
Obtains the vector composed of all Shape dimensions.
Prototype
std::vector<int64_t> GetDims() const
Parameters
None
Returns
Parameter |
Type |
Description |
---|---|---|
- |
std::vector<int64_t> |
Vector composed of dimensions of Shape. |
Exception Handling
None
Restrictions
None
GetDimNum
Description
Obtains the dimension count of Shape.
Prototype
size_t GetDimNum() const
Parameters
None
Returns
Parameter |
Type |
Description |
---|---|---|
- |
size_t |
Shape dimension count of the tensor |
Exception Handling
None
Restrictions
None
GetShapeSize
Description
Obtains the multiplication product of all dimensions of Shape.
Prototype
int64_t GetShapeSize() const
Parameters
None
Returns
Parameter |
Type |
Description |
---|---|---|
- |
int64_t |
Multiplication product of all dimensions. |
Exception Handling
None
Restrictions
None
SetDim
Description
Sets dimension idx in Shape to value.
Prototype
graphStatus SetDim(size_t idx, int64_t value)
Parameters
Parameter |
Input/Output |
Description |
---|---|---|
idx |
Input |
Dimension index of Shape, which starts from 0. |
value |
Input |
Value to be set. |
Returns
Parameter |
Type |
Description |
---|---|---|
- |
graphStatus |
GRAPH_SUCCESS on success; GRAPH_FAILED on failure |
Exception Handling
None
Restrictions
Before using the SetDim API, you can only use Shape(const std::vector<int64_t>& dims) to construct shape objects. If Shape() is used to construct a shape object, a failure code is returned by the call to SetDim.