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

Function get_perf_results

imperative/python/megengine/tools/benchmark_op.py:429–438  ·  view source on GitHub ↗
(mge_func, torch_func, shapes, unpack_inps, reps)

Source from the content-addressed store, hash-verified

427
428
429def get_perf_results(mge_func, torch_func, shapes, unpack_inps, reps):
430 inps = [np.random.randn(*shape) for shape in shapes]
431
432 inps_mge = [mge.tensor(inp, dtype="float32") for inp in inps]
433 avg_time_mge = get_avg_time(mge_func, inps_mge, reps, unpack_inps, True)
434
435 inps_torch = [torch.Tensor(inp).type(torch.float).cuda() for inp in inps]
436 avg_time_torch = get_avg_time(torch_func, inps_torch, reps, unpack_inps, False)
437
438 return avg_time_mge, avg_time_torch
439
440
441if __name__ == "__main__":

Callers 1

benchmark_op.pyFile · 0.85

Calls 4

get_avg_timeFunction · 0.85
tensorMethod · 0.80
typeMethod · 0.45
TensorMethod · 0.45

Tested by

no test coverage detected