code: def test_tensorize_vadd():
      def add(m):
          x = te.placeholder((m,), name="x")
          y = te.placeholder((m,), name="y")
          z = te.compute(x.shape, lambda i: x[i] + y[i], name="z")
          return x, y, z
  
      def check(m, factor):
          x, y, z = add(m)
          s = te.create_schedule(z.op)
          xo, xi = s[z].split(z.op.axis[0], factor=factor)
          vadd = intrin_vadd(xo, m, factor)
          s[z].tensorize(xi, vadd)
          s = s.normalize()
          dom_map = tvm.te.schedule.InferBound(s)
          finfer = tvm.get_global_func("test.op.InferTensorizeRegion")
          out_dom, in_dom = finfer(s[z], dom_map)
          assert tvm.ir.structural_equal(
              out_dom[z.op.axis[0]].extent, factor
          )
          assert tvm.ir.structural_equal(
              out_dom[z.op.axis[0]].min, xo * factor
          )
          assert tvm.ir.structural_equal(
              in_dom.items()[0][1][0].extent, factor
          )
          fmatch = tvm.get_global_func("test.op.MatchTensorizeBody")
          body = fmatch(s[z], out_dom, in_dom, vadd)
          ana = tvm.arith.Analyzer()
          assert tvm.ir.structural_equal(
              ana.simplify(body[0]), ana.simplify(vadd.op.body[0])
          )
          stmt = tvm.te.schedule.ScheduleOps(s, dom_map)
          tvm.lower(s, [x, y, z])
  
      def check_cache_write(m, factor):
          x, y, z = add(m)
          s = te.create_schedule(z.op)
          _, _ = s[z].split(z.op.axis[0], factor=factor)
  
          z_global = s.cache_write(z, "global")
          xo, xi = z_global.op.axis
  
          vadd = intrin_vadd(xo, m, factor)
          s[z_global].tensorize(xi, vadd)
          s = s.normalize()
          dom_map = tvm.te.schedule.InferBound(s)
          finfer = tvm.get_global_func("test.op.InferTensorizeRegion")
          out_dom, in_dom = finfer(s[z_global], dom_map)
          # outer loop var will be rebased, so min value is the new loop var and extent is 1
          assert tvm.ir.structural_equal(out_dom[xo].extent, 1)
          assert isinstance(out_dom[xo].min, tvm.tir.Var)
          assert xo.var.name == out_dom[xo].min.name
  
          fmatch = tvm.get_global_func("test.op.MatchTensorizeBody")
          body = fmatch(s[z_global], out_dom, in_dom, vadd)[0]
          ana = tvm.arith.Analyzer()
          vars = tvm.runtime.convert({xo.var: out_dom[xo].min})
          vadd_body = tvm.tir.stmt_functor.substitute(
              vadd.op.body[0], vars
          )
          assert tvm.ir.structural_equal(
              ana.simplify(body), ana.simplify(vadd_body)
          )
          stmt = tvm.te.schedule.ScheduleOps(s, dom_map)
          tvm.lower(s, [x, y, z])
  
      def check_compute_reuse():
          x, y, z = add(32)
  
          def _intrin_vadd():
              def _intrin_func(ins, outs):
                  return tvm.tir.call_packed(
                      "vadd", ins[0], ins[1], outs[0]
                  )
  
              return tvm.te.decl_tensor_intrin(z.op, _intrin_func)
  
          s = tvm.te.create_schedule(z.op)
          s[z].tensorize(z.op.axis[0], _intrin_vadd())
          tvm.lower(s, [x, y, z])
  
      check(128, 16)
      check_cache_write(129, 16)
      check_compute_reuse()
  
file_path: tvm/tests/python/te/test_te_schedule_tensorize.py
imports: import tvm
  from tvm import te
label_desc: Use image node_id 4 for calling a global function with example usage: test_tensorize_vadd() and returns: x,  y,  z, tvm, tvm