MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / test_matmul

Function test_matmul

imperative/python/test/unit/utils/test_network_node.py:133–154  ·  view source on GitHub ↗
(monkeypatch, benchmark_kernel, max_err)

Source from the content-addressed store, hash-verified

131 "benchmark_kernel, max_err", [(False, None), (True, 1e-5)],
132)
133def test_matmul(monkeypatch, benchmark_kernel, max_err):
134 if get_device_count("gpu") == 0 and benchmark_kernel:
135 return
136 monkeypatch.setenv("MGE_FASTRUN_CACHE_TYPE", "MEMORY")
137 old1, old2 = (
138 mge.config.benchmark_kernel,
139 mge.config.deterministic_kernel,
140 )
141 mge.config.benchmark_kernel = benchmark_kernel
142 mge.config.deterministic_kernel = True
143
144 @trace(symbolic=True, capture_as_const=True)
145 def fwd(data1, data2):
146 return F.matmul(data1, data2)
147
148 data1 = Tensor(np.random.random((32, 64)))
149 data2 = Tensor(np.random.random((64, 16)))
150 result = fwd(data1, data2)
151 check_pygraph_dump(fwd, [data1, data2], [result], max_err=max_err)
152 mge.config.benchmark_kernel = old1
153 mge.config.deterministic_kernel = old2
154 monkeypatch.delenv("MGE_FASTRUN_CACHE_TYPE", raising=False)
155
156
157def test_batchmatmul():

Callers

nothing calls this directly

Calls 4

get_device_countFunction · 0.90
TensorClass · 0.90
check_pygraph_dumpFunction · 0.85
fwdFunction · 0.70

Tested by

no test coverage detected