def solve_format_MinMax(optree): """ legalize Min or Max node """ lhs_value = optree.get_input(0) rhs_value = optree.get_input(1) unified_format = solve_equal_formats([optree, lhs_value, rhs_value]) format_set_if_undef(lhs_value, unified_format) format_set_if_undef(rhs_value, unified_format) return format_set_if_undef(optree, unified_format)
def solve_format_Select(optree): """ Legalize Select node """ assert isinstance(optree, Select) cond = optree.get_input(0) solve_format_BooleanOp(cond) true_value = optree.get_input(1) false_value = optree.get_input(2) unified_format = solve_equal_formats([optree, true_value, false_value]) format_set_if_undef(true_value, unified_format) format_set_if_undef(false_value, unified_format) return format_set_if_undef(optree, unified_format)
def solve_format_Comparison(optree): """ Legalize Comparison precision Args: optree (Comparison): input node Returns: (ML_Format) legalized node format """ assert isinstance(optree, Comparison) if optree.get_precision() is None: optree.set_precision(ML_Bool) lhs = optree.get_input(0) rhs = optree.get_input(1) merge_format = solve_equal_formats([lhs, rhs]) propagate_format_to_input(merge_format, optree, [0, 1]) return solve_format_BooleanOp(optree)