Skip to content

Commit a2aaa51

Browse files
authored
more fixes (#1459)
1 parent 2d9b0a1 commit a2aaa51

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/deepsparse/transformers/helpers.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def setup_transformers_pipeline(
6868
:param engine_kwargs: The kwargs to pass to the engine
6969
:return The model path, config, tokenizer, and engine kwargs
7070
"""
71-
model_path, config, tokenizer = setup_onnx_file_path(model_path, sequence_length)
71+
model_path, config, tokenizer = fetch_onnx_file_path(model_path, sequence_length)
7272

7373
tokenizer.padding_side = tokenizer_padding_side
7474
if not tokenizer.pad_token:
@@ -86,7 +86,7 @@ def setup_transformers_pipeline(
8686
return model_path, config, tokenizer, engine_kwargs
8787

8888

89-
def setup_onnx_file_path(
89+
def fetch_onnx_file_path(
9090
model_path: str,
9191
sequence_length: int,
9292
task: Optional[str] = None,
@@ -135,8 +135,6 @@ def get_deployment_path(model_path: str) -> Tuple[str, str]:
135135
for running the transformers model in the deepsparse pipeline
136136
137137
:param model_path: path to model directory, sparsezoo stub, or ONNX file
138-
:param onnx_model_name: name of the ONNX file to look for in the deployment
139-
directory. Defaults to MODEL_ONNX_NAME
140138
:return: path to the deployment directory and path to the ONNX file inside
141139
the deployment directory
142140
"""

src/deepsparse/v2/pipeline.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def __init__(
5454
ops: Union[Dict[str, Operator], List[Operator]],
5555
router: Router,
5656
schedulers: List[OperatorScheduler],
57-
continuous_batching_scheduler: ContinuousBatchingScheduler,
58-
pipeline_state: PipelineState = None,
57+
continuous_batching_scheduler: Optional[ContinuousBatchingScheduler] = None,
58+
pipeline_state: Optional[PipelineState] = None,
5959
):
6060

6161
self.ops = ops
@@ -277,7 +277,7 @@ def run(
277277
if operator_output is None:
278278
raise ValueError(
279279
f"{self.router.SPLIT_ROUTE} should appear after "
280-
f"{self.ROUTER.START_ROUTE}"
280+
f"{self.router.START_ROUTE}"
281281
)
282282

283283
operator_output = asyncio.run(

tests/deepsparse/v2/schedulers/test_continuous_batching_scheduler.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def test_continuous_batching_executor_thread():
2929
# mobilenet model with batch_size=2
3030
engine_operator = EngineOperator(
3131
"zoo:mobilenet_v2-1.0-imagenet-base",
32-
batch_size=1,
3332
)
3433

3534
scheduler.add_engine_operator(engine_operator, [1])

tests/deepsparse/v2/schedulers/utils/test_continuous_batching_executor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
def test_continuous_batching_executor_thread():
2828
# mobilenet model with batch_size=2
29-
engine_operator = EngineOperator("zoo:mobilenet_v2-1.0-imagenet-base", batch_size=2)
29+
engine_operator = EngineOperator("zoo:mobilenet_v2-1.0-imagenet-base")
3030

3131
# create queues object and add operator
3232
queues = ContinuousBatchingQueues()
33-
queues.add_queue(engine_operator, batch_sizes=[2])
33+
queues.add_queue(engine_operator, batch_sizes=[1])
3434

3535
# create engine map
36-
operators_to_engines = {engine_operator: {2: engine_operator.engine}}
36+
operators_to_engines = {engine_operator: {1: engine_operator.engine}}
3737

3838
worker_thread = ContinuousBatchingExecutorThread(queues, operators_to_engines)
3939

tests/deepsparse/v2/test_image_classification.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def test_image_classification(get_images):
3434
"zoo:cv/classification/resnet_v1-50/pytorch/sparseml/imagenet/pruned95-none"
3535
)
3636
pipeline = ImageClassificationPipeline(model_path=model_path)
37-
output = pipeline(ImageClassificationInput(images=get_images))
38-
assert output.labels == [[207], [670]]
39-
assert numpy.allclose(output.scores, [[21.85], [17.33]], atol=0.01)
37+
ground_truth = [[207], [670]]
38+
scores = [[21.85], [17.33]]
39+
40+
for i in range(len(get_images)):
41+
output = pipeline(ImageClassificationInput(images=get_images[i]))
42+
assert output.labels == ground_truth[i]
43+
assert numpy.allclose(output.scores, scores[i], atol=0.01)

0 commit comments

Comments
 (0)