提交 3c063649 authored 作者: Olivier Breuleux's avatar Olivier Breuleux

added option to PerformLinker

上级 1e01cf23
......@@ -115,8 +115,9 @@ class PerformLinker(Linker):
the L{Env} in the order given by L{Env.toposort}.
"""
def __init__(self, env):
def __init__(self, env, no_recycling = []):
self.env = env
self.no_recycling = no_recycling
def make_thunk(self, inplace = False, profiler = None):
if inplace:
......@@ -125,8 +126,14 @@ class PerformLinker(Linker):
env = self.env.clone(True)
order = env.toposort()
thunks = [op.perform for op in order]
no_recycling = self.no_recycling
if no_recycling is True:
no_recycling = list(env.results())
no_recycling = utils.difference(no_recycling, env.inputs)
if profiler is None:
def f():
for r in no_recycling:
r.data = None
try:
for thunk, op in zip(thunks, order):
thunk()
......@@ -134,6 +141,8 @@ class PerformLinker(Linker):
raise_with_op(op)
else:
def f():
for r in no_recycling:
r.data = None
def g():
for thunk, op in zip(thunks, order):
profiler.profile_op(thunk, op)
......
......@@ -317,7 +317,7 @@ def astensor(data, broadcastable=None, name=None):
raise ValueError("Cannot rename an existing Tensor.")
return data
elif isinstance(data, Result):
raise TypeError("Cannot make a Tensor out of a non-Tensor result:", data)
raise TypeError("Cannot make a Tensor out of a result that is not an instance of Tensor: %s (%s)" % (data, data.__class__.__name__), data)
if data is None and broadcastable is None:
raise TypeError("Cannot make a Tensor out of None.")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论