convert_ifelse

paddle.fluid.dygraph.dygraph_to_static.convert_operators. convert_ifelse ( pred, true_fn, false_fn, true_args, false_args, return_vars ) [source]

A function representation of a Python if/else statement.

Parameters
  • pred (bool|Tensor) – A boolean Tensor which determines whether to return the result of true_fn or false_fn .

  • true_fn (callable) – A callable to be performed if pred is true.

  • false_fn (callable) – A callable to be performed if pred is false.

  • true_args (tuple) – Parameters of true_fn.

  • false_args (tuple) – Parameters of false_fn.

  • return_vars (tuple) – Return variables of true_fn and false_fn.

Returns

true_fn(true_args) if the predicate pred is true else false_fn(false_args) .