Use Pytorch Benchmark on the forward+backward pass of an arbitrary function.
(
fn,
*inputs,
grad=None,
repeats=10,
desc="",
verbose=True,
amp=False,
amp_dtype=torch.float16,
**kwinputs,
)
| 115 | |
| 116 | |
| 117 | def benchmark_fwd_bwd( |
| 118 | fn, |
| 119 | *inputs, |
| 120 | grad=None, |
| 121 | repeats=10, |
| 122 | desc="", |
| 123 | verbose=True, |
| 124 | amp=False, |
| 125 | amp_dtype=torch.float16, |
| 126 | **kwinputs, |
| 127 | ): |
| 128 | """Use Pytorch Benchmark on the forward+backward pass of an arbitrary function.""" |
| 129 | return ( |
| 130 | benchmark_forward( |
| 131 | fn, |
| 132 | *inputs, |
| 133 | repeats=repeats, |
| 134 | desc=desc, |
| 135 | verbose=verbose, |
| 136 | amp=amp, |
| 137 | amp_dtype=amp_dtype, |
| 138 | **kwinputs, |
| 139 | ), |
| 140 | benchmark_backward( |
| 141 | fn, |
| 142 | *inputs, |
| 143 | grad=grad, |
| 144 | repeats=repeats, |
| 145 | desc=desc, |
| 146 | verbose=verbose, |
| 147 | amp=amp, |
| 148 | amp_dtype=amp_dtype, |
| 149 | **kwinputs, |
| 150 | ), |
| 151 | ) |
| 152 | |
| 153 | |
| 154 | def benchmark_all( |
nothing calls this directly
no test coverage detected