SetExpandDimsRule
Description
Sets the dimension expansion rule of a tensor.
Dimension expansion refers to adding one or more shapes based on the original shape. For example, if the original shape [2,2] has two axes, the shape after two dimensions are added between the two axes is [2,1,1,2]. The 0th and 3rd root axes of the shape after dimension expansion are called the original axis, and the 1st and 2nd root axes are called the dimension-expanded axis.
Here 1 and 0 are used to describe dimension expansion rules. The value 1 indicates that the current axis is the dimension-expanded axis, and the value 0 indicates that the current axis is the original axis. The values from left to right indicate the source of each axis of the current shape.
Dimension Expansion Rule |
Shape Before Dimension Expansion |
Shape After Dimension Expansion |
|---|---|---|
0110 |
[2, 2] |
[2, 1, 1, 2] |
100 |
[2, 3] |
[1, 2, 3] |
1000 |
[2, 3] |
The dimension expansion rule does not match the original shape. The rule specifies that there are three original axes, but the original shape has only two axes. As a result, an error is reported. |
Prototype
graphStatus SetExpandDimsRule(const AscendString &expand_dims_rule)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
expand_dims_rule |
Input |
expand_dims_rule dimension expansion rule to be set. The value is a character string. |
Returns
graphStatus type. GRAPH_SUCCESS on success; GRAPH_FAILED on failure.
Exception Handling
None.
Restrictions
None.