convert_logical_or

paddle.fluid.dygraph.dygraph_to_static.convert_operators. convert_logical_or ( x_func, y_func ) [source]

A function representation of a Python or statement.

Parameters
  • x_func (callable) – x_func() is the left hand operand of or operator. x_func() is bool or Tensor.

  • y_func (callable) – y_func() is the right hand operand of or operator. y_func() is bool or Tensor.

Returns

A python bool variable or a bool Tensor.

NOTE(liym27):

1) The operands are executed sequentially according to the running logic of Python. So here the arguments should be callable. 2) If the left hand operand is True, the right hand operand should be executed.

For example:

a = x > 1 or y < 1

Transformed code:

a = paddle.jit.dy2static.convert_logical_or(lambda:x>1, lambda:y<1)

In convert_logical_or(lambda:x>1, lambda:y<1), lambda:y<1 must be run after lambda:x>1. And if x>1 is True, y<1 should NOT be run.