Skip to content

Commit

Permalink
WIP/+ExecPlan class...
Browse files Browse the repository at this point in the history
- SAME x4 TCs FAIL like parent.
+ refact: revive net.steps --> net.last_plan
+ BREAK: inverse the order of outputs/inputs args in net.compute()
+ refact: use iset() to merge.
  • Loading branch information
ankostis committed Oct 4, 2019
1 parent d403783 commit 64e0028
Show file tree
Hide file tree
Showing 4 changed files with 357 additions and 304 deletions.
5 changes: 4 additions & 1 deletion graphkit/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,14 @@ def __init__(self, **kwargs):

def _compute(self, named_inputs, outputs=None):
return self.net.compute(
outputs, named_inputs, method=self._execution_method,
named_inputs, outputs, method=self._execution_method,
overwrites_collector=self._overwrites_collector)

def __call__(self, *args, **kwargs):
return self._compute(*args, **kwargs)

def compile(self, *args, **kwargs):
return self.net.compile(*args, **kwargs)

def set_execution_method(self, method):
"""
Expand Down
17 changes: 5 additions & 12 deletions graphkit/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,15 @@ def __call__(self, *operations):
merge_set = iset() # Preseve given node order.
for op in operations:
if isinstance(op, NetworkOperation):
op.net.compile()
net_ops = filter(lambda x: isinstance(x, Operation),
op.net.execution_plan)
merge_set.update(net_ops)
plan = op.net.compile()
merge_set.update(s for s in plan.steps
if isinstance(s, Operation))
else:
merge_set.add(op)
operations = merge_set

def order_preserving_uniquifier(seq, seen=None):
seen = seen if seen else set() # unordered, not iterated
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))]

provides = order_preserving_uniquifier(chain(*[op.provides for op in operations]))
needs = order_preserving_uniquifier(chain(*[op.needs for op in operations]),
set(provides)) # unordered, not iterated
provides = iset(chain(*[op.provides for op in operations]))
needs = iset(chain(*[op.needs for op in operations])) - provides

# Build network
net = Network()
Expand Down
Loading

0 comments on commit 64e0028

Please sign in to comment.