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)
| 115 | |
| 116 | |
| 117 | def _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 | |
| 137 | def test_tensorrt_conv1d(): |
no test coverage detected
searching dependent graphs…