mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Summary: This PR add a `--mode` flag and a script to collect microbenchmarks in a single JSON file. I also added a version check since benchmarks are expected to evolve; this also turned up a determinism bug in `init_from_variants`. (`set` is not ordered, unlike `dict`) Pull Request resolved: https://github.com/pytorch/pytorch/pull/55428 Test Plan: Run in CI CC: ngimel wconstab ezyang bhosmer Reviewed By: mruberry Differential Revision: D27775284 Pulled By: robieta fbshipit-source-id: c8c338fedbfb2860df207fe204212a0121ecb006
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Basic runner for the instruction count microbenchmarks.
|
|
|
|
The contents of this file are placeholders, and will be replaced by more
|
|
expressive and robust components (e.g. better runner and result display
|
|
components) in future iterations. However this allows us to excercise the
|
|
underlying benchmark generation infrastructure in the mean time.
|
|
"""
|
|
import argparse
|
|
import sys
|
|
from typing import List
|
|
|
|
from applications import ci
|
|
from core.expand import materialize
|
|
from definitions.standard import BENCHMARKS
|
|
from execution.runner import Runner
|
|
from execution.work import WorkOrder
|
|
|
|
|
|
def main(argv: List[str]) -> None:
|
|
work_orders = tuple(
|
|
WorkOrder(label, autolabels, timer_args, timeout=600, retries=2)
|
|
for label, autolabels, timer_args in materialize(BENCHMARKS)
|
|
)
|
|
|
|
results = Runner(work_orders).run()
|
|
for work_order in work_orders:
|
|
print(work_order.label, work_order.autolabels, work_order.timer_args.num_threads, results[work_order].instructions)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
modes = {
|
|
"debug": main,
|
|
"ci": ci.main,
|
|
}
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--mode", type=str, choices=list(modes.keys()), default="debug")
|
|
|
|
args, remaining_args = parser.parse_known_args(sys.argv)
|
|
modes[args.mode](remaining_args[1:])
|