提交 948c6813 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Hack to make Composite Ops compare equal when theano.config has changed

上级 4e80f755
......@@ -23,29 +23,35 @@ from theano.compile.mode import Mode, register_mode
AddConfigVar('DebugMode.patience',
"Optimize graph this many times to detect inconsistency",
IntParam(10, lambda i: i > 0))
IntParam(10, lambda i: i > 0),
in_c_key=False)
AddConfigVar('DebugMode.check_c',
"Run C implementations where possible",
BoolParam(True))
BoolParam(True),
in_c_key=False)
AddConfigVar('DebugMode.check_py',
"Run Python implementations where possible",
BoolParam(True))
BoolParam(True),
in_c_key=False)
AddConfigVar('DebugMode.check_finite',
"True -> complain about NaN/Inf results",
BoolParam(True))
BoolParam(True),
in_c_key=False)
AddConfigVar('DebugMode.check_strides',
("Check that Python- and C-produced ndarrays have same strides. "
"On difference: (0) - ignore, (1) warn, or (2) raise error"),
IntParam(1, lambda i: i in (0,1,2)))
IntParam(1, lambda i: i in (0,1,2)),
in_c_key=False)
AddConfigVar('DebugMode.warn_input_not_reused',
("Generate a warning when the destroy_map or view_map tell that an op work inplace, but the op did not reuse the input for its output."
),
BoolParam(True))
BoolParam(True),
in_c_key=False)
def is_valid_check_preallocated_output_param(param):
if not isinstance(param, str):
......
......@@ -2062,7 +2062,15 @@ class Composite(ScalarOp):
#TODO: What no_recycling is used for? What I need to put their?
# no_recycling = []
self._cmodule_key = gof.CLinker.cmodule_key_(self.env, [])
self._hashval = hash(self._cmodule_key)
# Remove the config md5 from _hashval
# This is a temporary fix so that _hashval does not change when
# the Op is pickled and unpickled.
cmkey = list(self._cmodule_key)
cmkey1 = list(cmkey[1])
assert isinstance(cmkey1[3], str) and cmkey1[3].startswith('md5:')
del cmkey1[3]
cmkey[1] = tuple(cmkey1)
self._hashval = hash(tuple(cmkey))
def __hash__(self):
return self._hashval
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论