numel

paddle. numel ( x, name=None ) [source]

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

Parameters
  • x (Tensor) – The input Tensor, it’s data type can be bool, float16, float32, float64, int32, int64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

The number of elements for the input Tensor, whose shape is [].

Return type

Tensor

Examples

import paddle

x = paddle.full(shape=[4, 5, 7], fill_value=0, dtype='int32')
numel = paddle.numel(x) # 140