rank

paddle.fluid.layers.rank(input)[source]

The OP returns the number of dimensions for a tensor, which is a 0-D int32 Tensor.

Parameters

input (Variable) – The input N-D tensor with shape of \([N_1, N_2, ..., N_k]\), the data type is arbitrary.

Returns

The 0-D tensor with the dimensions of the input variable.

Return type

Variable, the output data type is int32.

Examples

import paddle.fluid as fluid

input = fluid.data(name="input", shape=[3, 100, 100], dtype="float32")
rank = fluid.layers.rank(input) # rank=(3,)