convert_logical_and

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

A function representation of a Python and statement.

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

  • y_func (callable) – y_func() is the right hand operand of and 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 False, the right hand operand should be executed.

For example:

a = x > 1 and y < 1

Transformed code:

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

In convert_logical_and(lambda:x>1, lambda:y<1), lambda:y<1 must be run after lambda:x>1. And

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py:docstring of paddle.fluid.dygraph.dygraph_to_static.convert_operators.convert_logical_and, line 21)

Definition list ends without a blank line; unexpected unindent.

if x>1 is False, y<1 should NOT be run.