mindspore.ops.Shape
- class mindspore.ops.Shape[源代码]
Returns the shape of the input tensor. And it used to be static shape.
static shape: A shape that can be obtained without running the graph. It is an inherent property of tensor and may be unknown. The static shape information can be completed by artificial setting. No matter what the input of the graph is, the static shape is not affected.
- Inputs:
input_x (Tensor) - The shape of tensor is \((x_1, x_2, ..., x_R)\).
- Outputs:
tuple[int], the output tuple is constructed by multiple integers, \((x_1, x_2, ..., x_R)\).
- Raises
TypeError – If input_x is not a Tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> input_x = Tensor(np.ones(shape=[3, 2, 1]), mindspore.float32) >>> shape = ops.Shape() >>> output = shape(input_x) >>> print(output) (3, 2, 1)