MCPcopy Create free account
hub / github.com/apache/tvm / test_dnnl_offload

Function test_dnnl_offload

tests/python/relax/test_codegen_dnnl.py:66–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64
65
66def 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
95if __name__ == "__main__":

Callers 1

Calls 3

get_refFunction · 0.70
build_and_runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…