提交 888efc83 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Fix debugmode not to create c/py thunks when op does not support that.

上级 06d13855
...@@ -1191,6 +1191,12 @@ class _Linker(gof.link.LocalLinker): ...@@ -1191,6 +1191,12 @@ class _Linker(gof.link.LocalLinker):
try: try:
if not self.maker.mode.check_c_code: if not self.maker.mode.check_c_code:
raise utils.MethodNotDefined() raise utils.MethodNotDefined()
# Ops that do not inherit from gof.op.Op don't have certain
# methods defined that the CLinker expects (Scan is an
# exmaple, ifelse is another of such classes that inherit
# directly from PureOp)
if not isinstance(node.op, gof.op.Op):
raise utils.MethodNotDefined()
e = Env(*graph.clone(node.inputs, node.outputs)) e = Env(*graph.clone(node.inputs, node.outputs))
e.toposort = lambda: e.nodes #WARNING: STOCHASTIC ORDER e.toposort = lambda: e.nodes #WARNING: STOCHASTIC ORDER
# Specifically... e.nodes is a set, but of only 1 element # Specifically... e.nodes is a set, but of only 1 element
...@@ -1206,7 +1212,11 @@ class _Linker(gof.link.LocalLinker): ...@@ -1206,7 +1212,11 @@ class _Linker(gof.link.LocalLinker):
except (NotImplementedError, utils.MethodNotDefined): except (NotImplementedError, utils.MethodNotDefined):
thunks_c.append(None) thunks_c.append(None)
if self.maker.mode.check_py_code or thunks_c[-1] is None: # Pure ops don't really have a perform ( or their perform just
# raises an not implemented exception), so in those cases we
# consider that we don't have a python implementation
if ((self.maker.mode.check_py_code or thunks_c[-1] is None) and
node.op.perform.im_func != gof.op.PureOp.perform.im_func):
p = node.op.perform p = node.op.perform
thunk = (lambda p = p, i = node_input_storage, o = node_output_storage, n = thunk = (lambda p = p, i = node_input_storage, o = node_output_storage, n =
node: p(n, [x[0] for x in i], o)) node: p(n, [x[0] for x in i], o))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论