Skip to content

Default Config for Benchmark Pipeline #1268

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

Merged
merged 3 commits into from
Sep 25, 2023
Merged
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
10 changes: 7 additions & 3 deletions src/deepsparse/benchmark/benchmark_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/deepsparse/benchmark/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions src/deepsparse/benchmark/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pipeline_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down