"Fossies" - the Fresh Open Source Software Archive

Member "pytorch-1.8.2/benchmarks/overrides_benchmark/README.md" (23 Jul 2021, 2084 Bytes) of package /linux/misc/pytorch-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

__torch_function__ micro-benchmarks

This benchmark suite provides a systemic way to measure the performance of __torch_function__ overhead.

Getting started

Initial Setup

Install py-spy by doing:

pip install py-spy

Note that more extensive documentation on using py-spy is available in CONTRIBUTING.md.

Running the benchmark

Run one of the following commands in the terminal, with the working directory being ${PYTORCH_CLONE_DIR}/benchmarks/overrides_benchmark:

# Benchmark all the cases
python bench.py

# Flame graph pertaining to each case.
py-spy record -o tensor.svg --native -- python pyspybench.py Tensor
py-spy record -o subtensor.svg --native -- python pyspybench.py SubTensor
py-spy record -o overridden.svg --native -- python pyspybench.py WithTorchFunction
py-spy record -o suboverridden.svg --native -- python pyspybench.py SubWithTorchFunction

Here is a brief overview of what the results should look like, if run correctly:

Reporting benchmark results

When modifying any of the machinery around __torch_function__, run the benchmark for both the feature branch and the point it diverges from master. For each of these: