mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-03 04:12:48 +08:00
Summary: The shebang line `#!<path to interpreter>` is only required for Python scripts, so remove it on source files for class or function definitions. Additionally explicitly mark as executable the actual Python scripts in the codebase. Reviewed By: nikhilaravi Differential Revision: D20095778 fbshipit-source-id: d312599fba485e978a243292f88a180d71e1b55a
32 lines
1.0 KiB
Python
Executable File
32 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
|
|
|
import glob
|
|
import importlib
|
|
from os.path import basename, dirname, isfile, join, sys
|
|
|
|
if __name__ == "__main__":
|
|
# pyre-ignore[16]
|
|
if len(sys.argv) > 1:
|
|
# Parse from flags.
|
|
# pyre-ignore[16]
|
|
module_names = [n for n in sys.argv if n.startswith("bm_")]
|
|
else:
|
|
# Get all the benchmark files (starting with "bm_").
|
|
bm_files = glob.glob(join(dirname(__file__), "bm_*.py"))
|
|
module_names = [
|
|
basename(f)[:-3]
|
|
for f in bm_files
|
|
if isfile(f) and not f.endswith("bm_main.py")
|
|
]
|
|
|
|
for module_name in module_names:
|
|
module = importlib.import_module(module_name)
|
|
for attr in dir(module):
|
|
# Run all the functions with names "bm_*" in the module.
|
|
if attr.startswith("bm_"):
|
|
print(
|
|
"Running benchmarks for " + module_name + "/" + attr + "..."
|
|
)
|
|
getattr(module, attr)()
|