size

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

Size Layer

Returns the number of elements for a tensor, which is a int64 Tensor with shape [1].

Parameters

input (Variable) – The input variable.

Returns

The number of elements for the input variable.

Return type

Variable

Examples

import paddle.fluid.layers as layers

input = layers.data(
    name="input", shape=[3, 100], dtype="float32", append_batch_size=False)
rank = layers.size(input) # 300