code: def test_tir_int32_const_fold():
      """Behavior check: folding i32 operation match platform i32 arithmetic"""
  
      @T.prim_func
      def imm_multiply(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(x * y, dtype="int32"))
  
      @T.prim_func
      def imm_add(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(x + y, dtype="int32"))
  
      @T.prim_func
      def imm_sub(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(x - y, dtype="int32"))
  
      @T.prim_func
      def imm_truncdiv(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(T.truncdiv(x, y), dtype="int32"))
  
      @T.prim_func
      def imm_truncmod(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(T.truncmod(x, y), dtype="int32"))
  
      @T.prim_func
      def imm_floordiv(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(T.floordiv(x, y), dtype="int32"))
  
      @T.prim_func
      def imm_floormod(x: T.int32, y: T.int32) -> T.int32:
          T.evaluate(T.ret(T.floormod(x, y), dtype="int32"))
  
      fmul = tvm.build(imm_multiply, target="llvm")
      fadd = tvm.build(imm_add, target="llvm")
      fsub = tvm.build(imm_sub, target="llvm")
      ffloordiv = tvm.build(imm_floordiv, target="llvm")
      ffloormod = tvm.build(imm_floormod, target="llvm")
      ftruncdiv = tvm.build(imm_truncdiv, target="llvm")
      ftruncmod = tvm.build(imm_truncmod, target="llvm")
  
      # i32 overflow is not specified, only check for range
      assert (
          -(2**31)
          <= int(
              tir.const(2**31 - 1, "int32") + tir.const(1, "int32")
          )
          < 2**31
      )
      assert (
          -(2**31)
          <= int(tir.const(-(2**31), "int32") - tir.const(1, "int32"))
          < 2**31
      )
  
      # divide by zero
      with pytest.raises(tvm.TVMError):
          check_tir_const_fold(
              "int32", lambda x, y: tir.floordiv(x, y), ffloordiv, 1, 0
          )
      with pytest.raises(tvm.TVMError):
          check_tir_const_fold(
              "int32", lambda x, y: tir.floormod(x, y), ffloormod, 1, 0
          )
      with pytest.raises(tvm.TVMError):
          check_tir_const_fold(
              "int32", lambda x, y: tir.truncdiv(x, y), ftruncdiv, 1, 0
          )
      with pytest.raises(tvm.TVMError):
          check_tir_const_fold(
              "int32", lambda x, y: tir.truncmod(x, y), ftruncmod, 1, 0
          )
  
      # randomized check
      check_tir_const_fold(
          "int32", lambda x, y: x * y, fmul, skip_overflow=True
      )
      check_tir_const_fold(
          "int32", lambda x, y: x + y, fadd, skip_overflow=True
      )
      check_tir_const_fold(
          "int32", lambda x, y: x - y, fsub, skip_overflow=True
      )
      check_tir_const_fold(
          "int32",
          lambda x, y: tir.floordiv(x, y),
          ffloordiv,
          y_range=(1, np.iinfo("int32").max),
          skip_overflow=True,
      )
      check_tir_const_fold(
          "int32",
          lambda x, y: tir.truncdiv(x, y),
          ftruncdiv,
          y_range=(1, np.iinfo("int32").max),
          skip_overflow=True,
      )
      check_tir_const_fold(
          "int32",
          lambda x, y: tir.floormod(x, y),
          ffloormod,
          y_range=(1, np.iinfo("int32").max),
          skip_overflow=False,
      )
      check_tir_const_fold(
          "int32",
          lambda x, y: tir.truncmod(x, y),
          ftruncmod,
          y_range=(1, np.iinfo("int32").max),
          skip_overflow=False,
      )
  
imports: import math
  import random
  import numpy
  import tvm
  import tvm.testing
  import pytest
  from tvm import tir
  from tvm.script import tir
  import pytest
label_desc: Use image node_id 15 for calling a global function with example usage: test_tir_int32_const_fold() without return types