MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / main

Function main

tests/profile_subclass/profiling.py:45–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43
44
45def main():
46 global NUM_REPEATS
47 global NUM_REPEAT_OF_REPEATS
48
49 parser = argparse.ArgumentParser(description="Run the __torch_function__ benchmarks.")
50 parser.add_argument(
51 "--nreps", "-n", type=int, default=NUM_REPEATS, help="The number of repeats for one measurement."
52 )
53 parser.add_argument("--nrepreps", "-m", type=int, default=NUM_REPEAT_OF_REPEATS, help="The number of measurements.")
54 args = parser.parse_args()
55
56 NUM_REPEATS = args.nreps
57 NUM_REPEAT_OF_REPEATS = args.nrepreps
58
59 types = torch.Tensor, SubTensor, SubWithTorchFunc, MetaTensor
60
61 for t in types:
62 tensor_1 = t(1)
63 tensor_2 = t(2)
64
65 b_min, b_avg, b_med, b_std = bench(tensor_1, tensor_2)
66 print(
67 f"Type {t.__name__} time (microseconds):"
68 f" min: {10**6 * b_min}, avg: {(10**6) * b_avg}, median: {(10**6) * b_med}, and std {(10**6) * b_std}."
69 )
70
71
72if __name__ == "__main__":

Callers 1

profiling.pyFile · 0.85

Calls 1

benchFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…