diff --git a/src/deepsparse/benchmark/benchmark_pipeline.py b/src/deepsparse/benchmark/benchmark_pipeline.py index 373e6257bb..59c771d99e 100644 --- a/src/deepsparse/benchmark/benchmark_pipeline.py +++ b/src/deepsparse/benchmark/benchmark_pipeline.py @@ -87,7 +87,7 @@ import logging import threading import time -from typing import Dict, List, Tuple +from typing import Dict, List, Optional, Tuple import click import numpy @@ -237,7 +237,7 @@ def create_input_schema( def benchmark_pipeline( model_path: str, task: str, - config: PipelineBenchmarkConfig, + config: Optional[PipelineBenchmarkConfig] = None, batch_size: int = 1, num_cores: int = None, scenario: str = "sync", @@ -274,6 +274,10 @@ def benchmark_pipeline( if num_cores is None: num_cores = cpu_architecture().num_available_physical_cores + if config is None: + _LOGGER.warning("No input configuration provided, falling back to default.") + config = PipelineBenchmarkConfig() + decide_thread_pinning(thread_pinning) scenario = parse_scenario(scenario.lower()) scheduler = parse_scheduler(scenario) @@ -364,7 +368,7 @@ def calculate_section_stats( "-c", "--input_config", type=str, - default="config.json", + default=None, help="JSON file containing schema for input data", ) @click.option( diff --git a/src/deepsparse/benchmark/config.py b/src/deepsparse/benchmark/config.py index 6829116758..e1cf9c1972 100644 --- a/src/deepsparse/benchmark/config.py +++ b/src/deepsparse/benchmark/config.py @@ -34,14 +34,14 @@ class PipelineBenchmarkConfig(BaseModel): ) gen_sequence_length: Optional[int] = Field( - default=None, + default=512, description=( "Number of characters to generate for pipelines that take text input." ), ) input_image_shape: Optional[List[int]] = Field( - default=None, + default=[224, 224, 3], description=( "Image size for pipelines that take image input, 3-dim with channel as the " "last dimmension" diff --git a/src/deepsparse/benchmark/helpers.py b/src/deepsparse/benchmark/helpers.py index 703dafa92c..1d1235ead7 100644 --- a/src/deepsparse/benchmark/helpers.py +++ b/src/deepsparse/benchmark/helpers.py @@ -123,6 +123,10 @@ def parse_num_streams(num_streams: int, num_cores: int, scenario: str): def parse_input_config(input_config_file: str) -> Dict[str, any]: + if input_config_file is None: + _LOGGER.warning("No input configuration file provided, using default.") + return PipelineBenchmarkConfig() + config_file = open(input_config_file) config = json.load(config_file) config_file.close() diff --git a/tests/test_pipeline_benchmark.py b/tests/test_pipeline_benchmark.py index 485599d044..a0ff49f60a 100644 --- a/tests/test_pipeline_benchmark.py +++ b/tests/test_pipeline_benchmark.py @@ -64,6 +64,11 @@ "1", ], ), + ( + "image_classification", + "zoo:cv/classification/resnet_v1-50_2x/pytorch/sparseml/imagenet/base-none", + [], + ), ( "token_classification", "zoo:nlp/token_classification/distilbert-none/pytorch/huggingface/"