xref: /aosp_15_r20/external/pytorch/benchmarks/fastrnns/README.md (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard Worker# Fast RNN benchmarks
2*da0073e9SAndroid Build Coastguard Worker
3*da0073e9SAndroid Build Coastguard WorkerBenchmarks for TorchScript models
4*da0073e9SAndroid Build Coastguard Worker
5*da0073e9SAndroid Build Coastguard WorkerFor most stable results, do the following:
6*da0073e9SAndroid Build Coastguard Worker- Set CPU Governor to performance mode (as opposed to energy save)
7*da0073e9SAndroid Build Coastguard Worker- Turn off turbo for all CPUs (assuming Intel CPUs)
8*da0073e9SAndroid Build Coastguard Worker- Shield cpus via `cset shield` when running benchmarks.
9*da0073e9SAndroid Build Coastguard Worker
10*da0073e9SAndroid Build Coastguard WorkerSome of these scripts accept command line args but most of them do not because
11*da0073e9SAndroid Build Coastguard WorkerI was lazy. They will probably be added sometime in the future, but the default
12*da0073e9SAndroid Build Coastguard Workersizes are pretty reasonable.
13*da0073e9SAndroid Build Coastguard Worker
14*da0073e9SAndroid Build Coastguard Worker## Test fastrnns (fwd + bwd) correctness
15*da0073e9SAndroid Build Coastguard Worker
16*da0073e9SAndroid Build Coastguard WorkerTest the fastrnns benchmarking scripts with the following:
17*da0073e9SAndroid Build Coastguard Worker`python -m fastrnns.test`
18*da0073e9SAndroid Build Coastguard Workeror run the test independently:
19*da0073e9SAndroid Build Coastguard Worker`python -m fastrnns.test --rnns jit`
20*da0073e9SAndroid Build Coastguard Worker
21*da0073e9SAndroid Build Coastguard Worker## Run benchmarks
22*da0073e9SAndroid Build Coastguard Worker
23*da0073e9SAndroid Build Coastguard Worker`python -m fastrnns.bench`
24*da0073e9SAndroid Build Coastguard Worker
25*da0073e9SAndroid Build Coastguard Workershould give a good comparison, or you can specify the type of model to run
26*da0073e9SAndroid Build Coastguard Worker
27*da0073e9SAndroid Build Coastguard Worker`python -m fastrnns.bench --rnns cudnn aten jit --group rnns`
28*da0073e9SAndroid Build Coastguard Worker
29*da0073e9SAndroid Build Coastguard Worker## Run model profiling, calls nvprof
30*da0073e9SAndroid Build Coastguard Worker
31*da0073e9SAndroid Build Coastguard Worker`python -m fastrnns.profile`
32*da0073e9SAndroid Build Coastguard Worker
33*da0073e9SAndroid Build Coastguard Workershould generate nvprof file for all models somewhere.
34*da0073e9SAndroid Build Coastguard Workeryou can also specify the models to generate nvprof files separately:
35*da0073e9SAndroid Build Coastguard Worker
36*da0073e9SAndroid Build Coastguard Worker`python -m fastrnns.profile --rnns aten jit`
37*da0073e9SAndroid Build Coastguard Worker
38*da0073e9SAndroid Build Coastguard Worker### Caveats
39*da0073e9SAndroid Build Coastguard Worker
40*da0073e9SAndroid Build Coastguard WorkerUse Linux for the most accurate timing. A lot of these tests only run
41*da0073e9SAndroid Build Coastguard Workeron CUDA.
42