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

support shallow copy of pipelines #262

Merged
merged 4 commits into from Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions fuse/data/pipelines/pipeline_default.py
Expand Up @@ -22,6 +22,8 @@
from fuse.utils.ndict import NDict
from fuse.utils.cpu_profiling.timer import Timer

import copy


class PipelineDefault(OpReversibleBase):
"""
Expand Down Expand Up @@ -54,6 +56,15 @@ def __init__(
self._op_ids = op_ids
self._verbose = verbose

def copy(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice,
Can you please add in a comment that it is a shallow copy (both pipelines will still use the same instances of ops)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
This is a shallow copy of the pipeline: the two pipelines will point to the same operation instances.
"""
self_copy = copy.copy(self)
self_copy._ops_and_kwargs = copy.copy(self_copy._ops_and_kwargs)
self_copy._op_ids = copy.copy(self_copy._op_ids)
return self_copy

def extend(self, ops_and_kwargs: List[Tuple[OpBase, dict]], op_ids: Optional[List[str]] = None):
"""
Extends pipeline
Expand Down