code: def test_binary_dtype_match():
      def verify_general_dtype_support(f, is_conditional=False):
          rules = [
              [("bool", "int32"), "int32"],
              [("int32", "float32"), "float32"],
              [("int32", "int64"), "int64"],
              [("uint32", "int8"), "uint32"],
              [("uint32", "int32"), "uint32"],
          ]
          for (lhs_dtype, rhs_dtype), out_dtype in rules:
              lhs = te.var("lhs", dtype=lhs_dtype)
              rhs = te.var("rhs", dtype=rhs_dtype)
              out = f(lhs, rhs)
              if not is_conditional:
                  assert out.dtype == out_dtype
              else:
                  assert out.dtype == "bool"
              if hasattr(out, "a"):
                  assert out.a.dtype == out_dtype
                  assert out.b.dtype == out_dtype
              elif hasattr(out, "args"):
                  # CallOp
                  assert out.args[0].dtype == out_dtype
                  assert out.args[1].dtype == out_dtype
              else:
                  raise ValueError("Unknown binary op format!")
  
      def verify_callop_float_only(f):
          for lhs_dtype in ["int32", "float32", "float64"]:
              for rhs_dtype in ["int32", "float32", "float64"]:
                  lhs = te.var("lhs", dtype=lhs_dtype)
                  rhs = te.var("rhs", dtype=rhs_dtype)
                  if (
                      "float" not in lhs_dtype
                      and "float" not in rhs_dtype
                  ):
                      check_throws(lambda: f(lhs, rhs))
                  elif "float" in lhs_dtype:
                      out = f(lhs, rhs)
  
                      # Upcasting for floating point types
                      dtypes = [lhs_dtype, rhs_dtype]
                      if "float64" in dtypes:
                          target_dtype = "float64"
                      elif "float32" in dtypes:
                          target_dtype = "float32"
                      else:
                          target_dtype = "int32"
                      assert out.dtype == target_dtype
  
                      # Final inputs are the right type
                      assert out.args[0].dtype == target_dtype
                      assert out.args[1].dtype == target_dtype
                  else:
                      out = f(lhs, rhs)
                      assert out.dtype == rhs_dtype
                      assert out.args[0].dtype == rhs_dtype
                      assert out.args[1].dtype == rhs_dtype
  
      verify_general_dtype_support(lambda a, b: a + b)
      verify_general_dtype_support(lambda a, b: a * b)
      verify_general_dtype_support(
          lambda a, b: a >= b, is_conditional=True
      )
      verify_general_dtype_support(
          lambda a, b: a <= b, is_conditional=True
      )
      verify_callop_float_only(lambda a, b: te.power(a, b))
  
      # verify bool & int32 constant folding
      assert tvm.tir.const(1) == tvm.tir.const(True)
      assert tvm.tir.const(2) != tvm.tir.const(True)
  
file_path: tvm/tests/python/tir-base/test_tir_ops.py
imports: import tvm
  import tvm.testing
  from tvm import te
  import pytest
label_desc: Use image node_id 6 for calling a global function with example usage: test_binary_dtype_match() without return types