提交 ca4ad1ee authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merged -- no conflict

...@@ -1923,7 +1923,7 @@ class Composite(ScalarOp): ...@@ -1923,7 +1923,7 @@ class Composite(ScalarOp):
super(Composite,out).__init__(output_types_preference, name) super(Composite,out).__init__(output_types_preference, name)
return out return out
def __init__(self, inputs, outputs): def __init__(self, inputs, outputs, rehash=True):
self.inputs=copy(inputs) self.inputs=copy(inputs)
self.outputs=copy(outputs) self.outputs=copy(outputs)
...@@ -2004,6 +2004,7 @@ class Composite(ScalarOp): ...@@ -2004,6 +2004,7 @@ class Composite(ScalarOp):
self.env = env self.env = env
self.inputs_type = tuple([input.type for input in self.env.inputs]) self.inputs_type = tuple([input.type for input in self.env.inputs])
self.outputs_type = tuple([output.type for output in self.env.outputs]) self.outputs_type = tuple([output.type for output in self.env.outputs])
if rehash:
self._rehash() self._rehash()
def output_types(self, input_types): def output_types(self, input_types):
...@@ -2055,6 +2056,7 @@ class Composite(ScalarOp): ...@@ -2055,6 +2056,7 @@ class Composite(ScalarOp):
if not isinstance(other, self.__class__): return False if not isinstance(other, self.__class__): return False
if self.nin!=other.nin or self.nout != other.nout: return False if self.nin!=other.nin or self.nout != other.nout: return False
return self._hashval == other._hashval return self._hashval == other._hashval
# TODO The second `return` is useless. Should there be an `and`?
return self._cmodule_key == other._cmodule_key return self._cmodule_key == other._cmodule_key
def _rehash(self): def _rehash(self):
...@@ -2074,6 +2076,9 @@ class Composite(ScalarOp): ...@@ -2074,6 +2076,9 @@ class Composite(ScalarOp):
def __setstate__(self, d): def __setstate__(self, d):
self.__dict__.update(d) self.__dict__.update(d)
#we must call init to set env and _impls again. # We must call init to set env and _impls again, as otherwise
#otherwise self.perform won't work. # self.perform will not work.
self.__init__(self.inputs, self.outputs) # However, we should not call `_rehash` because it may yield a
# different hash if some config options have changed, which would make
# the loaded object look different from the original.
self.__init__(self.inputs, self.outputs, rehash=False)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论