提交 62d84b6c authored 作者: Olivier Breuleux's avatar Olivier Breuleux

fixed issue with the user retrieving results from the outputs he provided

上级 aa07dc65
...@@ -10,9 +10,15 @@ from copy import copy ...@@ -10,9 +10,15 @@ from copy import copy
class profile_linker: class profile_linker:
def __init__(self, env): def __init__(self, env):
self.order = env.toposort() self.order = env.toposort()
# print "digraph unix { size = '6,6'; node [color = lightblue2; style = filled];"
# for op in self.order:
# for input in op.inputs:
# if input.owner:
# print input.owner.__class__.__name__ + str(abs(id(input.owner))), " -> ", op.__class__.__name__ + str(abs(id(op))), ";"
self.thunks = [op._perform for op in self.order] self.thunks = [op._perform for op in self.order]
self.n_calls = 0 self.n_calls = 0
self.times = [0.0 for op in self.order] self.times = [0.0 for op in self.order]
def __call__(self): def __call__(self):
for i, thunk in enumerate(self.thunks): for i, thunk in enumerate(self.thunks):
start_time = time.time() start_time = time.time()
...@@ -51,13 +57,14 @@ class prog(gof.Prog): ...@@ -51,13 +57,14 @@ class prog(gof.Prog):
TODO: think about whether orphan computation should be in this function, TODO: think about whether orphan computation should be in this function,
or in self.__call__() or in self.__call__()
""" """
outputs = gof.mark_outputs_as_destroyed(outputs) new_outputs = gof.mark_outputs_as_destroyed(outputs)
gof.Prog.__init__(self, gof.Prog.__init__(self,
inputs, inputs,
outputs, new_outputs,
optimizer, optimizer,
linker, linker,
[]) [])
self.outputs = outputs
self.compute_orphans() self.compute_orphans()
def __call__(self, check_uncomputed = True): def __call__(self, check_uncomputed = True):
......
...@@ -193,6 +193,8 @@ class NumpyR(gof.PythonR): ...@@ -193,6 +193,8 @@ class NumpyR(gof.PythonR):
self.data = UNCOMPUTED self.data = UNCOMPUTED
elif isinstance(value, numpy.ndarray): elif isinstance(value, numpy.ndarray):
self.data = value self.data = value
elif isinstance(value, PythonR):
self.set_value(value.data)
else: else:
self.data = numpy.array(value) self.data = numpy.array(value)
self.up_to_date = True self.up_to_date = True
......
...@@ -34,5 +34,6 @@ optimizer_end = gof.SeqOptimizer([gof.DummyRemover]) ...@@ -34,5 +34,6 @@ optimizer_end = gof.SeqOptimizer([gof.DummyRemover])
def optimizer(lst): def optimizer(lst):
seq_opt = gof.SeqOptimizer(optimizer_begin + lst + optimizer_end) seq_opt = gof.SeqOptimizer(optimizer_begin + lst + optimizer_end)
rval = gof.PythonOpt(gof.MergeOptMerge(seq_opt)) rval = gof.PythonOpt(gof.MergeOptMerge(seq_opt))
# rval = gof.PythonOpt((seq_opt))
return rval return rval
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论