MCPcopy Index your code
hub / github.com/apache/tvm / check_saved_func

Function check_saved_func

python/tvm/relax/testing/vm.py:78–87  ·  view source on GitHub ↗
(vm: relax.VirtualMachine, func_name: str, *inputs: list[Any])

Source from the content-addressed store, hash-verified

76
77
78def check_saved_func(vm: relax.VirtualMachine, func_name: str, *inputs: list[Any]) -> Object:
79 # uses save_function to create a closure with the given inputs
80 # and ensure the result is the same
81 # (assumes the functions return tensors and that they're idempotent)
82 saved_name = f"{func_name}_saved"
83 vm.save_function(func_name, saved_name, *inputs)
84 res1 = vm[func_name](*inputs)
85 res2 = vm[saved_name]()
86 tvm.testing.assert_allclose(res1.numpy(), res2.numpy(), rtol=1e-7, atol=1e-7)
87 return res1
88
89
90@tvm.register_global_func("test.vm.check_if_defined")

Calls 2

save_functionMethod · 0.80
numpyMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…