提交 b7b7f5cc authored 作者: Frederic Bastien's avatar Frederic Bastien

Change datastructure to a deque that is faster. Queue is for multi-thread…

Change datastructure to a deque that is faster. Queue is for multi-thread communication with automatic locking.
上级 cdefae1b
...@@ -15,7 +15,6 @@ from . import graph ...@@ -15,7 +15,6 @@ from . import graph
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
from .fg import InconsistencyError from .fg import InconsistencyError
from six.moves.queue import Queue
class ProtocolError(Exception): class ProtocolError(Exception):
...@@ -210,13 +209,14 @@ def _build_droot_impact(destroy_handler): ...@@ -210,13 +209,14 @@ def _build_droot_impact(destroy_handler):
# The code here add all the variables that are views of r into # The code here add all the variables that are views of r into
# an OrderedSet input_impact # an OrderedSet input_impact
input_impact = OrderedSet() input_impact = OrderedSet()
queue = Queue()
queue.put(input_root) q = deque()
while not queue.empty(): q.append(input_root)
v = queue.get() while len(q) > 0:
v = q.popleft()
for n in destroy_handler.view_o.get(v, []): for n in destroy_handler.view_o.get(v, []):
input_impact.add(n) input_impact.add(n)
queue.put(n) q.append(n)
for v in input_impact: for v in input_impact:
assert v not in droot assert v not in droot
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论