()
| 43 | |
| 44 | |
| 45 | def 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 | |
| 72 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…