code: def test_vectorized_casts():
      def check(t0, t1, factor):
          if (t0 == "float16" or t1 == "float16") and not have_fp16(
              tvm.cuda(0).compute_version
          ):
              print("Skip because gpu does not have fp16 support")
              return
  
          # compute
          n = 128
          A = te.placeholder((n,), dtype=t0, name="A")
          B = te.placeholder((n,), dtype=t1, name="B")
          C = te.compute(
              (n,), lambda i: A[i] + topi.cast(B[i], A.dtype), name="C"
          )
  
          # schedule
          s = tvm.te.create_schedule(C.op)
          ob, ib = s[C].split(s[C].op.axis[0], factor=factor)
          s[C].vectorize(ib)
          s[C].bind(ob, tx)
          func = tvm.build(s, [A, B, C], "cuda")
  
          # correctness
          dev = tvm.cuda(0)
          low, high = (
              (0, 20)
              if t0.startswith("u") or t1.startswith("u")
              else (-10, 10)
          )
          a_np = np.random.randint(low, high, size=n).astype(A.dtype)
          b_np = np.random.randint(low, high, size=n).astype(B.dtype)
          c_np = (a_np + b_np).astype(A.dtype)
          a_nd = tvm.nd.array(a_np, dev)
          b_nd = tvm.nd.array(b_np, dev)
          c_nd = tvm.nd.array(
              np.zeros(c_np.shape, dtype=c_np.dtype), dev
          )
          func(a_nd, b_nd, c_nd)
          tvm.testing.assert_allclose(c_nd.numpy(), c_np, rtol=1e-3)
  
      def skip(t0, t1):
          if t0 == t1:
              return True
          # CUDA does support cast between {u}int8 and fp16.
          skip_set = {"float16", "uint8", "int8"}
          if t0 in skip_set and t1 in skip_set:
              return True
          return False
  
      types_4 = [
          "float16",
          "float32",
          "int8",
          "uint8",
          "int16",
          "uint16",
          "int32",
          "uint32",
          "float64",
          "int64",
          "uint64",
      ]
      types_8 = [
          "float16",
          "float32",
          "int8",
          "uint8",
          "int16",
          "uint16",
          "int32",
          "uint32",
      ]
      for t0, t1 in [
          (x, y) for x in types_4 for y in types_4 if not skip(x, y)
      ]:
          check(t0, t1, 4)
      for t0, t1 in [
          (x, y) for x in types_8 for y in types_8 if not skip(x, y)
      ]:
          check(t0, t1, 8)
      check("int8", "uint8", 16)
      check("uint8", "int8", 16)
  
imports: import os
  import re
  import tvm
  from tvm import te
  import numpy
  from tvm import topi
  from tvm.contrib.nvcc import have_fp16, have_int8, have_bf16
  from tvm.contrib import utils
  from tvm.script import tir
  import tvm.testing
  import pytest
label_desc: Use image node_id 18 for calling a global function with example usage: test_vectorized_casts() and returns: False, True, True