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

Function gen_matmul_data

imperative/python/test/unit/core/test_custom_op.py:161–168  ·  view source on GitHub ↗
(seed, m, k, n, low=-0.5, high=0.5, dtype=np.float32)

Source from the content-addressed store, hash-verified

159 return apply(op, ograd, self.lhs, self.rhs)
160
161 def gen_matmul_data(seed, m, k, n, low=-0.5, high=0.5, dtype=np.float32):
162 rng = np.random.RandomState(seed=seed)
163 lhs_np = rng.uniform(low=low, high=high, size=(m, k)).astype(dtype)
164 rhs_np = rng.uniform(low=low, high=high, size=(k, n)).astype(dtype)
165 ograd_np = rng.uniform(low=low, high=high, size=(m, n)).astype(dtype)
166 scale = rng.uniform(low=0.1, high=0.9, size=(1)).astype(np.float32)[0]
167
168 return lhs_np, rhs_np, ograd_np, scale
169
170 def builtin_func(lhs, rhs, scale):
171 out = F.matmul(lhs, rhs) * scale

Callers 2

test_matmul_scaleFunction · 0.85
test_matmul_scale_traceFunction · 0.85

Calls 3

RandomStateMethod · 0.80
uniformMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected