paddle.fluid.dygraph.dygraph_to_static.convert_operators. convert_shape_compare ( left, *args ) [source]

A function handles comparison difference between Paddle and Python. For example, if x and y are Tensors, x.shape == y.shape will return single boolean Value (True/False). However, paddle.shape(x) == paddle.shape(y) is an element-wise comparison. The difference can cause dy2stat error. So we create this function to handle the difference.

  • left – variable

  • *args – compare_op(str), variable, compare_op(str), variable, where compare_op means “<”, “>”, “==”, “!=”, etc.


If the variables to compare are NOT Paddle Variables, we will return as Python like “a op1 b and b op2 c and … “. If the variables to compare are Paddle Variables, we will do elementwise comparsion first and then reduce to a boolean whose numel is 1.