()
| 64 | |
| 65 | |
| 66 | def test_dnnl_offload(): |
| 67 | pat = make_fused_bias_activation_pattern( |
| 68 | "relax.nn.conv2d", with_bias=False, activation="relax.nn.relu" |
| 69 | ) |
| 70 | |
| 71 | seq = tvm.transform.Sequential( |
| 72 | [ |
| 73 | relax.transform.FuseOpsByPattern([("dnnl.conv2d_relu", pat)]), |
| 74 | relax.transform.MergeCompositeFunctions(), |
| 75 | relax.transform.RunCodegen(), |
| 76 | ] |
| 77 | ) |
| 78 | |
| 79 | @memoize("relax.tests.test_codegen_dnnl.conv2d_relu_x2") |
| 80 | def get_ref(): |
| 81 | data_np = np.random.randn(1, 64, 56, 56).astype("float32") |
| 82 | weight1_np = np.random.randn(64, 64, 3, 3).astype("float32") |
| 83 | weight2_np = np.random.randn(64, 64, 3, 3).astype("float32") |
| 84 | inputs = [data_np, weight1_np, weight2_np] |
| 85 | ref = build_and_run(Conv2dReLUx2, inputs, legalize=True) |
| 86 | return inputs, ref |
| 87 | |
| 88 | inputs, ref = get_ref() |
| 89 | |
| 90 | out = build_and_run(seq(Conv2dReLUx2), inputs) |
| 91 | |
| 92 | tvm.testing.assert_allclose(out, ref, rtol=1e-3, atol=1e-3) |
| 93 | |
| 94 | |
| 95 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…