Skip to content

Commit 3d9622b

Browse files
author
Sara Adkins
authored
Default Config for Benchmark Pipeline (#1268)
* add a default for pipeline benchmarking * review
1 parent 9a4c5cc commit 3d9622b

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

Diff for: src/deepsparse/benchmark/benchmark_pipeline.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
import logging
8888
import threading
8989
import time
90-
from typing import Dict, List, Tuple
90+
from typing import Dict, List, Optional, Tuple
9191

9292
import click
9393
import numpy
@@ -237,7 +237,7 @@ def create_input_schema(
237237
def benchmark_pipeline(
238238
model_path: str,
239239
task: str,
240-
config: PipelineBenchmarkConfig,
240+
config: Optional[PipelineBenchmarkConfig] = None,
241241
batch_size: int = 1,
242242
num_cores: int = None,
243243
scenario: str = "sync",
@@ -274,6 +274,10 @@ def benchmark_pipeline(
274274
if num_cores is None:
275275
num_cores = cpu_architecture().num_available_physical_cores
276276

277+
if config is None:
278+
_LOGGER.warning("No input configuration provided, falling back to default.")
279+
config = PipelineBenchmarkConfig()
280+
277281
decide_thread_pinning(thread_pinning)
278282
scenario = parse_scenario(scenario.lower())
279283
scheduler = parse_scheduler(scenario)
@@ -364,7 +368,7 @@ def calculate_section_stats(
364368
"-c",
365369
"--input_config",
366370
type=str,
367-
default="config.json",
371+
default=None,
368372
help="JSON file containing schema for input data",
369373
)
370374
@click.option(

Diff for: src/deepsparse/benchmark/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ class PipelineBenchmarkConfig(BaseModel):
3434
)
3535

3636
gen_sequence_length: Optional[int] = Field(
37-
default=None,
37+
default=512,
3838
description=(
3939
"Number of characters to generate for pipelines that take text input."
4040
),
4141
)
4242

4343
input_image_shape: Optional[List[int]] = Field(
44-
default=None,
44+
default=[224, 224, 3],
4545
description=(
4646
"Image size for pipelines that take image input, 3-dim with channel as the "
4747
"last dimmension"

Diff for: src/deepsparse/benchmark/helpers.py

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ def parse_num_streams(num_streams: int, num_cores: int, scenario: str):
123123

124124

125125
def parse_input_config(input_config_file: str) -> Dict[str, any]:
126+
if input_config_file is None:
127+
_LOGGER.warning("No input configuration file provided, using default.")
128+
return PipelineBenchmarkConfig()
129+
126130
config_file = open(input_config_file)
127131
config = json.load(config_file)
128132
config_file.close()

Diff for: tests/test_pipeline_benchmark.py

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
"1",
6565
],
6666
),
67+
(
68+
"image_classification",
69+
"zoo:cv/classification/resnet_v1-50_2x/pytorch/sparseml/imagenet/base-none",
70+
[],
71+
),
6772
(
6873
"token_classification",
6974
"zoo:nlp/token_classification/distilbert-none/pytorch/huggingface/"

0 commit comments

Comments
 (0)