提交 b1dc85bc authored 作者: Caglar's avatar Caglar

added the shared variable zero fn.

上级 e9e94b4c
......@@ -113,6 +113,22 @@ class SharedVariable(Variable):
else:
self.container.value = copy.deepcopy(new_value)
def zero(self, borrow=False):
"""Set the values of a shared variable to 0.
:param borrow:
True to modify the value of a shared variable directly by using
its previous value. Potentially this can cause problems
regarding to the aliased memory.
Changes done with this function will be visible to all functions using
this SharedVariable.
"""
if borrow:
self.container.value = 0 * self.container.value
else:
self.container.value = 0 * copy.deepcopy(self.container.value)
def clone(self):
cp = self.__class__(
name=self.name,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论