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

Function build_and_run

tests/python/relax/test_codegen_cudnn.py:113–131  ·  view source on GitHub ↗
(mod, inputs_np, target, legalize=False, cuda_graph=False)

Source from the content-addressed store, hash-verified

111
112
113def build_and_run(mod, inputs_np, target, legalize=False, cuda_graph=False):
114 dev = tvm.device(target, 0)
115 with tvm.transform.PassContext(
116 config={
117 "relax.backend.use_cuda_graph": cuda_graph,
118 "relax.transform.apply_legalize_ops": legalize,
119 }
120 ):
121 ex = tvm.compile(mod, target)
122 vm = relax.VirtualMachine(ex, dev)
123 f = vm["main"]
124 inputs = [tvm.runtime.tensor(inp, dev) for inp in inputs_np]
125
126 # For cuda graph, run the compiled function twice to make sure that we can launch the cached
127 # graph on the second run.
128 if cuda_graph:
129 f(*inputs)
130
131 return f(*inputs).numpy()
132
133
134@pytest.mark.parametrize(

Callers 3

test_conv2d_offloadFunction · 0.70

Calls 4

numpyMethod · 0.80
fFunction · 0.70
deviceMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…