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

Add minor updates #1265

Merged
merged 2 commits into from
Sep 22, 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
4 changes: 2 additions & 2 deletions src/deepsparse/benchmark/stream_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def model_stream_benchmark(
# given amount of wallclock time. This calculation as-is includes the test overhead
# such as saving timing results for each iteration so it isn't a best-case but is a
# realistic case.
first_start_time = min([b[0] for b in batch_times])
last_end_time = max([b[1] for b in batch_times])
first_start_time = min(b[0] for b in batch_times)
last_end_time = max(b[1] for b in batch_times)
total_time_executing = last_end_time - first_start_time

items_per_sec = (model.batch_size * len(batch_times)) / total_time_executing
Expand Down
5 changes: 1 addition & 4 deletions src/deepsparse/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ def __call__(self, *args, **kwargs) -> BaseModel:
# ------ POSTPROCESSING ------
timer.start(InferenceStages.POST_PROCESS)
pipeline_outputs = self.process_engine_outputs(engine_outputs, **context)
if not (
isinstance(pipeline_outputs, (self.output_schema, Generator))
or isinstance(pipeline_outputs, Generator)
):
if not isinstance(pipeline_outputs, (self.output_schema, Generator)):
raise ValueError(
f"Outputs of {self.__class__} must be instances of "
f"{self.output_schema} found output of type "
Expand Down
2 changes: 1 addition & 1 deletion src/deepsparse/transformers/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def add_batch(self, predictions: List[str]):
list(compress(sequence, attn_mask))
for (sequence, attn_mask) in zip(encoded_batch, attention_mask)
]
max_sequence_len = max([len(sequence) for sequence in encoded_batch])
max_sequence_len = max(len(sequence) for sequence in encoded_batch)

encoded_batch = [
pad_to_fixed_length(numpy.array(sequence), max_sequence_len)
Expand Down
4 changes: 2 additions & 2 deletions src/deepsparse/transformers/pipelines/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ def join_engine_outputs(
# different lengths

# find the longest sequence in the batch of tokens
max_len = max([token.shape[1] for token in tokens])
max_len = max(token.shape[1] for token in tokens)

# pad all tokens to the same length
tokens = [
Expand All @@ -942,7 +942,7 @@ def join_engine_outputs(
]

# find the longest sequence in the batch of logits
max_len = max([logits.shape[1] for logits in logits])
max_len = max(logits.shape[1] for logits in logits)

# pad all logits to the same length
logits = [
Expand Down
Loading