提交 599630e7 authored 作者: James Bergstra's avatar James Bergstra

fixed eq in CSM

上级 915ccd0f
......@@ -138,6 +138,13 @@ class NodeFinder(dict, Bookkeeper):
self.setdefault(node.op, []).append(node)
except TypeError: #node.op is unhashable
return
except Exception, e:
print >> sys.stderr, 'OFFENDING node', type(node), type(node.op)
try:
print >> sys.stderr, 'OFFENDING node hash', hash(node.op)
except:
print >> sys.stderr, 'OFFENDING node not hashable'
raise e
def on_prune(self, env, node):
try:
......
......@@ -256,10 +256,10 @@ class CSM(gof.Op):
def __eq__(self, other):
return type(other) is CSM \
and other.format == self.format and other.map==self.map
and other.format == self.format and numpy.all(other.map==self.map)
def __hash__(self):
return hash(CSM) ^ hash(self.format) ^ hash(numpy.str(self.map))
return hash(type(self)) ^ hash(self.format) ^ hash(numpy.str(self.map))
def make_node(self, data, indices, indptr, shape):
"""Build a SparseResult from the internal parametrization
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论