code: def test_vtcm_limit(vtcm_capacity, limited):
      """Test building with vtcm mem scope limit"""
      sch = get_scale_by_two_schedule()
  
      def _raises_exception(f):
          try:
              f()
          except tvm._ffi.base.TVMError:
              return True
          return False
  
      target = get_hexagon_target("v68", vtcm_capacity=vtcm_capacity)
  
      assert (
          _raises_exception(lambda: tvm.build(sch.mod, target=target))
          == limited
      ), "Case 1 - arg. VTCM memory allocation limiter does not work correctly "
  
      with target:
          assert (
              _raises_exception(lambda: tvm.build(sch.mod)) == limited
          ), "Case 2 - with.VTCM memory allocation limiter does not work correctly "
  
      with tvm.transform.PassContext(
          config={"tir.vtcm_capacity": vtcm_capacity}
      ):
          assert (
              _raises_exception(
                  lambda: tvm.build(
                      sch.mod,
                      target=get_hexagon_target("v68", vtcm_capacity=0),
                  )
              )
              == limited
          ), "Case 3 - context. VTCM memory allocation limiter does not work correctly "
  
file_path: tvm/tests/python/contrib/test_hexagon/test_vtcm.py
imports: import pytest
  import tvm.testing
  from tvm import tir
  from tvm.script import tir
  from .infrastructure import get_hexagon_target
label_desc: Use image node_id 4 for calling a global function with example usage: test_vtcm_limit(vtcm_capacity, limited) and returns: False, True