提交 eb12d76b authored 作者: James Bergstra's avatar James Bergstra

revision to eq and hash of scalar.Composite

上级 3e7666ba
...@@ -2074,17 +2074,25 @@ class Composite(ScalarOp): ...@@ -2074,17 +2074,25 @@ class Composite(ScalarOp):
return str return str
def __eq__(self, other): def __eq__(self, other):
if self is other: return True if self is other:
if not isinstance(other, self.__class__): return False return True
if self.nin!=other.nin or self.nout != other.nout: return False if (type(self) != type(other)
return self._hashval == other._hashval or self.nin != other.nin
# TODO The second `return` is useless. Should there be an `and`? or self.nout != other.nout):
return self._cmodule_key == other._cmodule_key return False
rval = (self._cmodule_key == other._cmodule_key)
if rval:
assert hash(self) == hash(other)
return rval
def _rehash(self): def _rehash(self):
#TODO: What no_recycling is used for? What I need to put their? # delete the configparser md5 part out of the module key
# no_recycling = [] # because for the purpose of identifying same/different
self._cmodule_key = gof.CLinker.cmodule_key_(self.env, []) # Composite Ops, the flags governing C code generation are
# irrelevant.
self._cmodule_key = gof.CLinker.cmodule_key_(self.env,
no_recycling=[], # irrelevant for comparing graphs
insert_config_md5=False)
self._hashval = hash(self._cmodule_key) self._hashval = hash(self._cmodule_key)
def __hash__(self): def __hash__(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论