Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added force [False] to .benchmark(), forces benchmarking local #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions torchbench/image_classification/cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -70,6 +71,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(
Expand Down
2 changes: 2 additions & 0 deletions torchbench/image_classification/cifar100.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -70,6 +71,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(
Expand Down
2 changes: 2 additions & 0 deletions torchbench/image_classification/imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:
"""Benchmarking function.

Expand Down Expand Up @@ -206,6 +207,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(
Expand Down
2 changes: 2 additions & 0 deletions torchbench/image_classification/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -69,6 +70,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(
Expand Down
2 changes: 2 additions & 0 deletions torchbench/image_classification/stl10.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -69,6 +70,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(
Expand Down
2 changes: 2 additions & 0 deletions torchbench/image_classification/svhn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -72,6 +73,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(
Expand Down
38 changes: 20 additions & 18 deletions torchbench/image_classification/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def evaluate_classification(
model_output_transform,
send_data_to_device,
device="cuda",
force=False
):
top1 = AverageMeter()
top5 = AverageMeter()
Expand Down Expand Up @@ -45,24 +46,25 @@ def evaluate_classification(
iterator.close()
break

# get the cached values from sotabench.com if available
client = Client.public()
cached_res = client.get_results_by_run_hash(run_hash)
if cached_res:
iterator.close()
print(
"No model change detected (using the first batch run "
"hash). Returning cached results."
)

speed_mem_metrics = {
'Tasks / Evaluation Time': None,
'Evaluation Time': None,
'Tasks': None,
'Max Memory Allocated (Total)': None,
}

return cached_res, speed_mem_metrics, run_hash
if not force:
# get the cached values from sotabench.com if available
client = Client.public()
cached_res = client.get_results_by_run_hash(run_hash)
if cached_res:
iterator.close()
print(
"No model change detected (using the first batch run "
"hash). Returning cached results."
)

speed_mem_metrics = {
'Tasks / Evaluation Time': None,
'Evaluation Time': None,
'Tasks': None,
'Max Memory Allocated (Total)': None,
}

return cached_res, speed_mem_metrics, run_hash

exec_time = (time.time() - init_time)

Expand Down
22 changes: 12 additions & 10 deletions torchbench/language_modelling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def evaluate_language_model(
model_output_transform,
send_data_to_device,
device="cuda",
force=False
):
n_steps, eval_loss = 0, 0

Expand Down Expand Up @@ -50,15 +51,16 @@ def evaluate_language_model(
iterator.close()
break

# get the cached values from sotabench.com if available
client = Client.public()
cached_res = client.get_results_by_run_hash(run_hash)
if cached_res:
iterator.close()
print(
"No model change detected (using the first batch "
"run_hash). Returning cached results."
)
return cached_res, run_hash
if not force:
# get the cached values from sotabench.com if available
client = Client.public()
cached_res = client.get_results_by_run_hash(run_hash)
if cached_res:
iterator.close()
print(
"No model change detected (using the first batch "
"run_hash). Returning cached results."
)
return cached_res, run_hash

return {"Perplexity": np.exp(eval_loss / n_steps)}, run_hash
3 changes: 3 additions & 0 deletions torchbench/language_modelling/wikitext103.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -66,6 +67,7 @@ def benchmark(
send_data_to_device=cls.send_data_to_device,
test_loader=test_loader,
device=device,
force=force
)

# Valid Split
Expand All @@ -90,6 +92,7 @@ def benchmark(
send_data_to_device=cls.send_data_to_device,
test_loader=valid_loader,
device=device,
force=force
)

# Get final results
Expand Down
2 changes: 2 additions & 0 deletions torchbench/object_detection/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:
"""Benchmarking function.

Expand Down Expand Up @@ -223,6 +224,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(test_results)
Expand Down
38 changes: 20 additions & 18 deletions torchbench/object_detection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def evaluate_detection_coco(
model_output_transform,
send_data_to_device,
device="cuda",
force=False
):

coco = get_coco_api_from_dataset(test_loader.dataset)
Expand Down Expand Up @@ -222,24 +223,25 @@ def evaluate_detection_coco(
iterator.close()
break

# get the cached values from sotabench.com if available
client = Client.public()
cached_res = client.get_results_by_run_hash(run_hash)
if cached_res:
iterator.close()
print(
"No model change detected (using the first batch run "
"hash). Returning cached results."
)

speed_mem_metrics = {
'Tasks / Evaluation Time': None,
'Evaluation Time': None,
'Tasks': None,
'Max Memory Allocated (Total)': None,
}

return cached_res, speed_mem_metrics, run_hash
if not force:
# get the cached values from sotabench.com if available
client = Client.public()
cached_res = client.get_results_by_run_hash(run_hash)
if cached_res:
iterator.close()
print(
"No model change detected (using the first batch run "
"hash). Returning cached results."
)

speed_mem_metrics = {
'Tasks / Evaluation Time': None,
'Evaluation Time': None,
'Tasks': None,
'Max Memory Allocated (Total)': None,
}

return cached_res, speed_mem_metrics, run_hash

exec_time = (time.time() - init_time)

Expand Down
2 changes: 2 additions & 0 deletions torchbench/semantic_segmentation/ade20k.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -91,6 +92,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(test_results)
Expand Down
2 changes: 2 additions & 0 deletions torchbench/semantic_segmentation/camvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -91,6 +92,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(test_results)
Expand Down
2 changes: 2 additions & 0 deletions torchbench/semantic_segmentation/cityscapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -94,6 +95,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(test_results)
Expand Down
2 changes: 2 additions & 0 deletions torchbench/semantic_segmentation/pascalcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -91,6 +92,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)

print(test_results)
Expand Down
2 changes: 2 additions & 0 deletions torchbench/semantic_segmentation/pascalvoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def benchmark(
paper_pwc_id: str = None,
paper_results: dict = None,
pytorch_hub_url: str = None,
force: bool = False
) -> BenchmarkResult:

config = locals()
Expand Down Expand Up @@ -136,6 +137,7 @@ def benchmark(
model_output_transform=model_output_transform,
send_data_to_device=send_data_to_device,
device=device,
force=force
)
print(test_results)

Expand Down
Loading