paddle.fluid.layers.control_flow. increment ( x, value=1.0, in_place=True ) [source]

The OP is usually used for control flow to increment the data of x by an amount value. Notice that the number of elements in x must be equal to 1.

  • x (Variable) – A tensor that must always contain only one element, its data type supports float32, float64, int32 and int64.

  • value (float, optional) – The amount to increment the data of x. Default: 1.0.

  • in_place (bool, optional) – Whether the OP should be performed in-place. Default: True.


The elementwise-incremented tensor with the same shape and data type as x.

Return type



import paddle.fluid as fluid
counter = fluid.layers.zeros(shape=[1], dtype='float32') # [0.]
fluid.layers.increment(counter) # [1.]