code: def test_subspace_division():
      x = tvm.tir.Var("x", "int32")
      y = tvm.tir.Var("y", "int32")
      z = tvm.tir.Var("z", "int32")
      c = tvm.tir.SizeVar("c", "int32")
  
      # simple 1.1
      res = tvm.arith.subspace_divide(
          [z * 12 + y * 3 + x + c],
          var_dom([(x, 3), (y, 4), (z, 5)]),
          [x],
      )
      res = convert_division(res)
      assert len(res) == 2
      tvm.ir.assert_structural_equal(res[0][0], z * 4 + y)
      tvm.ir.assert_structural_equal(res[0][1], x + c)
  
      # simple 1.2
      res = tvm.arith.subspace_divide(
          [z * 12 + y * 3 + x + c],
          var_dom([(x, 3), (y, 4), (z, 5)]),
          [x],
          z * 4 + y < 18,
      )
      res = convert_division(res)
      assert len(res) == 2
      tvm.ir.assert_structural_equal(res[0][0], z * 4 + y)
      tvm.ir.assert_structural_equal(res[0][1], x + c)
      tvm.ir.assert_structural_equal(res[1][0], z * 4 + y < 18)
      tvm.ir.assert_structural_equal(res[1][1], True)
  
      # compound 1
      i0 = create_iter("i0", 4)
      j0 = create_iter("j0", 8)
      i3 = create_iter("i3", 2)
  
      i1, i2 = isplit(j0, 4)
      k0 = ifuse([i0, i1])
      k1 = ifuse([i2, i3])
  
      # compound 1.1
      res = tvm.arith.subspace_divide(
          [k0[0], k1[0]], var_dom([i0, j0, i3]), [i3[0]]
      )
      res = convert_division(res)
      assert len(res) == 3
      tvm.ir.assert_structural_equal(
          res[0][0], (i0[0] * 2) + floordiv(j0[0], 4)
      )
      tvm.ir.assert_structural_equal(res[0][1], 0)
      tvm.ir.assert_structural_equal(res[1][0], floormod(j0[0], 4))
      tvm.ir.assert_structural_equal(res[1][1], i3[0])
  
      assert_iter_sum_pattern
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1]], var_dom([i3])
      ).indices
      assert len(res1) == 2
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0]], var_dom([i0, j0])
      ).indices
      assert len(res2) == 2
  
      # compound 1.2
      res = tvm.arith.subspace_divide(
          [k0[0], k1[0]], var_dom([i0, j0, i3]), [j0[0], i3[0]]
      )
      res = convert_division(res)
      assert len(res) == 3
      tvm.ir.assert_structural_equal(res[0][0], i0[0])
      tvm.ir.assert_structural_equal(res[0][1], floordiv(j0[0], 4))
      tvm.ir.assert_structural_equal(res[1][0], 0)
      tvm.ir.assert_structural_equal(
          res[1][1], (floormod(j0[0], 4) * 2) + i3[0]
      )
  
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1]], var_dom([j0, i3])
      ).indices
      assert len(res1) == 2
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0]], var_dom([i0])
      ).indices
      assert len(res2) == 2
  
      # compound 1.3
      res = tvm.arith.subspace_divide(
          [k0[0], k1[0]], var_dom([i0, j0, i3]), [i0[0], i3[0]]
      )
      res = convert_division(res)
      assert len(res) == 0
  
      # compound 1.4
      res = tvm.arith.subspace_divide(
          [k0[0], k1[0]], var_dom([i0, j0, i3]), [i3[0]], k0[0] < 7
      )
      res = convert_division(res)
      assert len(res) == 3
      tvm.ir.assert_structural_equal(
          res[0][0], (i0[0] * 2) + floordiv(j0[0], 4)
      )
      tvm.ir.assert_structural_equal(res[0][1], 0)
      tvm.ir.assert_structural_equal(res[1][0], floormod(j0[0], 4))
      tvm.ir.assert_structural_equal(res[1][1], i3[0])
      tvm.ir.assert_structural_equal(
          res[2][0], (i0[0] * 2) + floordiv(j0[0], 4) < 7
      )
      tvm.ir.assert_structural_equal(res[2][1], True)
  
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1]], var_dom([i3])
      ).indices
      assert len(res1) == 2
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0]], var_dom([i0, j0])
      ).indices
      assert len(res2) == 2
  
      # compound 1.5
      res = tvm.arith.subspace_divide(
          [k0[0], k1[0]],
          var_dom([i0, j0, i3]),
          [j0[0], i3[0]],
          k1[0] < 7,
      )
      res = convert_division(res)
      assert len(res) == 3
      tvm.ir.assert_structural_equal(res[0][0], i0[0])
      tvm.ir.assert_structural_equal(res[0][1], floordiv(j0[0], 4))
      tvm.ir.assert_structural_equal(res[1][0], 0)
      tvm.ir.assert_structural_equal(
          res[1][1], (floormod(j0[0], 4) * 2) + i3[0]
      )
      tvm.ir.assert_structural_equal(res[2][0], True)
      tvm.ir.assert_structural_equal(
          res[2][1], (floormod(j0[0], 4) * 2) + i3[0] < 7
      )
  
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1]], var_dom([j0, i3])
      ).indices
      assert len(res1) == 2
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0]], var_dom([i0])
      ).indices
      assert len(res2) == 2
  
      # compound 1.6
      res = tvm.arith.subspace_divide(
          [k0[0], k1[0]],
          var_dom([i0, j0, i3]),
          [i3[0]],
          tvm.tir.all(k0[0] < 7, k1[0] < 7),
      )
      res = convert_division(res)
      assert len(res) == 0
  
      # compound 2
      j0 = create_iter("j0", 4)
      l0 = create_iter("l0", 2)
      l1 = create_iter("l1", 6)
      j3 = create_iter("j3", 3)
  
      k0 = ifuse([l0, l1])
      i1, j2 = isplit(k0, 3)
      j1, i1 = isplit(i1, 2)
      i0 = ifuse([j0, j1])
      i2 = ifuse([j2, j3])
  
      # compound 2.1
      res = tvm.arith.subspace_divide(
          [i0[0], i1[0], i2[0]],
          var_dom([j0, l0, l1, j3]),
          [l1[0], j3[0]],
      )
      res = convert_division(res)
      assert len(res) == 4
      tvm.ir.assert_structural_equal(res[0][0], (j0[0] * 2) + l0[0])
      tvm.ir.assert_structural_equal(res[0][1], 0)
      tvm.ir.assert_structural_equal(res[1][0], 0)
      tvm.ir.assert_structural_equal(res[1][1], floordiv(l1[0], 3))
      tvm.ir.assert_structural_equal(res[2][0], 0)
      tvm.ir.assert_structural_equal(
          res[2][1], (floormod(l1[0], 3) * 3) + j3[0]
      )
  
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1], res[2][1]], var_dom([l1, j3])
      ).indices
      assert len(res1) == 3
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0], res[2][0]], var_dom([j0, l0])
      ).indices
      assert len(res2) == 3
  
      # compound 2.2
      res = tvm.arith.subspace_divide(
          [i0[0], i1[0], i2[0]],
          var_dom([j0, l0, l1, j3]),
          [l0[0], l1[0], j3[0]],
      )
      res = convert_division(res)
      assert len(res) == 4
      tvm.ir.assert_structural_equal(res[0][0], j0[0])
      tvm.ir.assert_structural_equal(
          res[0][1], floordiv(l0[0] * 6 + l1[0], 6)
      )
      tvm.ir.assert_structural_equal(res[1][0], 0)
      tvm.ir.assert_structural_equal(
          res[1][1], floordiv(floormod(l0[0] * 6 + l1[0], 6), 3)
      )
      tvm.ir.assert_structural_equal(res[2][0], 0)
      tvm.ir.assert_structural_equal(
          res[2][1], (floormod(l0[0] * 6 + l1[0], 3) * 3) + j3[0]
      )
  
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1], res[2][1]], var_dom([l0, l1, j3])
      ).indices
      assert len(res1) == 3
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0], res[2][0]], var_dom([j0])
      ).indices
      assert len(res2) == 3
  
      # compound 2.3
      res = tvm.arith.subspace_divide(
          [i0[0], i1[0], i2[0]],
          var_dom([j0, l0, l1, j3]),
          [l0[0], j3[0]],
      )
      res = convert_division(res)
      assert len(res) == 0
  
      # compound 2.4
      res = tvm.arith.subspace_divide(
          [i0[0], i1[0], i2[0]],
          var_dom([j0, l0, l1, j3]),
          [l1[0], j3[0]],
          tvm.tir.all(i0[0] < 7, i2[0] < 8),
      )
      res = convert_division(res)
      assert len(res) == 4
      tvm.ir.assert_structural_equal(res[0][0], (j0[0] * 2) + l0[0])
      tvm.ir.assert_structural_equal(res[0][1], 0)
      tvm.ir.assert_structural_equal(res[1][0], 0)
      tvm.ir.assert_structural_equal(res[1][1], floordiv(l1[0], 3))
      tvm.ir.assert_structural_equal(res[2][0], 0)
      tvm.ir.assert_structural_equal(
          res[2][1], (floormod(l1[0], 3) * 3) + j3[0]
      )
      tvm.ir.assert_structural_equal(res[3][0], (j0[0] * 2) + l0[0] < 7)
      tvm.ir.assert_structural_equal(
          res[3][1], (floormod(l1[0], 3) * 3) + j3[0] < 8
      )
  
      res1 = tvm.arith.detect_iter_map(
          [res[0][1], res[1][1], res[2][1]], var_dom([l1, j3])
      ).indices
      assert len(res1) == 3
      res2 = tvm.arith.detect_iter_map(
          [res[0][0], res[1][0], res[2][0]], var_dom([j0, l0])
      ).indices
      assert len(res2) == 3
  
      # compound 2.5
      res = tvm.arith.subspace_divide(
          [i0[0], i1[0], i2[0]],
          var_dom([j0, l0, l1, j3]),
          [j3[0]],
          i2[0] < 8,
      )
      res = convert_division(res)
      assert len(res) == 0
  
imports: import tvm
  import tvm.testing
  from tvm.tir import floordiv, floormod
label_desc: Use image node_id 16 for calling a global function with example usage: test_subspace_division() without return types