Skip to content

Commit

Permalink
remove redundant operations
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunwoongko committed Dec 29, 2021
1 parent ccaea51 commit e52b73a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
26 changes: 1 addition & 25 deletions parallelformers/parallelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ def hijack(
Returns:
Any: outputs of model
"""

try:
for i_mutex, i_queue in zip(
self.inference_mutexes,
Expand All @@ -334,32 +333,9 @@ def hijack(
outputs = []
for o_queue in self.outputs_queues:
output = o_queue.get()
outputs.append(output)
# consumer part

if isinstance(output, ModelOutput) or _is_dataclass_instance(
output
):
_output = output
elif isinstance(output, tuple) or isinstance(output, list):
_output = []
for o in output:
if torch.is_tensor(o):
o = o.clone().to("cpu")
_output.append(o)
elif isinstance(output, dict):
_output = {}
for k, v in output.items():
if torch.is_tensor(v):
v = v.clone().to("cpu")
_output[k] = v
else:
_output = output
if torch.is_tensor(output):
_output = output.clone().to("cpu")

del output
outputs.append(_output)

if func in self._memory_logger:
final_output = dict(outputs)
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='parallelformers',
version='1.2.2',
version='1.2.3',
description=
'An Efficient Model Parallelization Toolkit for Deployment',
long_description=long_description,
Expand Down

0 comments on commit e52b73a

Please sign in to comment.