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

Function _offload_and_compare

tests/python/relax/test_codegen_tensorrt.py:117–134  ·  view source on GitHub ↗

Offload a single-op module to TensorRT and compare against the LLVM reference. Each module here contains a single instance of the op under test, which both exercises the individual converter and avoids the structurally-identical-composite deduplication that would otherwise collapse repe

(mod, params_np, patterns, data_np, rtol=1e-2, atol=1e-2)

Source from the content-addressed store, hash-verified

115
116
117def _offload_and_compare(mod, params_np, patterns, data_np, rtol=1e-2, atol=1e-2):
118 """Offload a single-op module to TensorRT and compare against the LLVM reference.
119
120 Each module here contains a single instance of the op under test, which both exercises the
121 individual converter and avoids the structurally-identical-composite deduplication that would
122 otherwise collapse repeated ops.
123 """
124 ref = build_and_run(mod, [data_np, *params_np.values()], "llvm", legalize=True)
125 offloaded = tvm.transform.Sequential(
126 [
127 relax.transform.BindParams("main", params_np),
128 relax.transform.FuseOpsByPattern(patterns),
129 relax.transform.MergeCompositeFunctions(),
130 relax.transform.RunCodegen(),
131 ]
132 )(mod)
133 out = build_and_run(offloaded, [data_np], "cuda")
134 tvm.testing.assert_allclose(out, ref, rtol=rtol, atol=atol)
135
136
137def test_tensorrt_conv1d():

Callers 8

test_tensorrt_conv1dFunction · 0.85
test_tensorrt_max_pool2dFunction · 0.85
test_tensorrt_avg_pool2dFunction · 0.85
test_tensorrt_softmaxFunction · 0.85
test_tensorrt_sigmoidFunction · 0.85
test_tensorrt_tanhFunction · 0.85

Calls 2

build_and_runFunction · 0.70
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…