benchmark
d9fa6b8d - Make it easier to add more backends (#1059)

Commit
3 years ago
Make it easier to add more backends (#1059) Summary: This PR makes it easier to add more backends. To add a new backend: 1. create a file, say `jit.py`, in https://github.com/pytorch/benchmark/tree/main/torchbenchmark/util/backends. 2. In the file, create a function, say `def torchsript(model, backend_args)`, to transform the model using your backend, or add run contexts to it. 3. In https://github.com/pytorch/benchmark/blob/5a857e97721019eb0aa622976a8ac378cd4f2fbb/torchbenchmark/util/backends/__init__.py#L35, register your backend with import, e.g., `from .jit import torchscript`. You can now try your own backend with your own backend: `python run.py <model-name> --backend <backend-name> <backend-options`, for example: ``` $ python run.py resnet50 --backend torchscript CPU Total Wall Time: 667.329 milliseconds Correctness: True $ python run.py resnet50 --backend torchscript --no-ofi CPU Total Wall Time: 1633.694 milliseconds Correctness: True ``` Pull Request resolved: https://github.com/pytorch/benchmark/pull/1059 Reviewed By: erichan1 Differential Revision: D38139725 Pulled By: xuzhao9 fbshipit-source-id: 4d578c4ddb94276755b7ae3ae80b794e3b1e6920
Author
Parents
Loading