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

Pass arguments for pipeline creation properly to deepsparse.evaluate #1624

Merged
merged 7 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
7 changes: 4 additions & 3 deletions src/deepsparse/evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def evaluate(

# if target is a string, turn it into an appropriate pipeline
# otherwise assume it is a pipeline
pipeline = (
create_pipeline(model, engine_type) if isinstance(model, (Path, str)) else model
)
if isinstance(model, (Path, str)):
pipeline, kwargs = create_pipeline(model, engine_type, **kwargs)
dbogunowicz marked this conversation as resolved.
Show resolved Hide resolved
else:
pipeline = model

eval_integration = EvaluationRegistry.resolve(pipeline, datasets, integration)

Expand Down
16 changes: 9 additions & 7 deletions src/deepsparse/evaluation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,13 @@ def create_pipeline(
:return: The initialized pipeline
horheynm marked this conversation as resolved.
Show resolved Hide resolved
dbogunowicz marked this conversation as resolved.
Show resolved Hide resolved
"""
engine_type = engine_type or DEEPSPARSE_ENGINE
return Pipeline.create(
task=kwargs.pop("task", "text-generation"),
model_path=model_path,
sequence_length=kwargs.pop("sequence_length", 2048),
engine_type=engine_type,
batch_size=kwargs.pop("batch_size", 1),
**kwargs,
return (
Pipeline.create(
task=kwargs.pop("task", "text-generation"),
model_path=model_path,
sequence_length=kwargs.pop("sequence_length", 2048),
engine_type=engine_type,
batch_size=kwargs.pop("batch_size", 1),
),
kwargs,
)
4 changes: 2 additions & 2 deletions tests/deepsparse/evaluation/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def pipeline_target():


def test_initialize_model_from_target_pipeline_onnx(pipeline_target):
model = create_pipeline(pipeline_target, "onnxruntime")
model, _ = create_pipeline(pipeline_target, "onnxruntime")
assert model.ops.get("single_engine")._engine_type == "onnxruntime"


def test_initialize_model_from_target_pipeline_with_kwargs(pipeline_target):
model = create_pipeline(pipeline_target, "deepsparse", sequence_length=64)
model, _ = create_pipeline(pipeline_target, "deepsparse", sequence_length=64)
assert model.ops.get("process_input").sequence_length == 64
Loading