提交 c6585dd3 authored 作者: Frederic's avatar Frederic

[CRASH] add {SliceType,NoneTypeT}.may_share_memory()

上级 53699fe9
...@@ -58,6 +58,11 @@ class SliceType(Type): ...@@ -58,6 +58,11 @@ class SliceType(Type):
def __hash__(self): def __hash__(self):
return hashtype(self) return hashtype(self)
@staticmethod
def may_share_memory(a, b):
# Slices never shared memory between object
return isinstance(a, slice) and a is b
slicetype = SliceType() slicetype = SliceType()
...@@ -72,6 +77,12 @@ class NoneTypeT(Generic): ...@@ -72,6 +77,12 @@ class NoneTypeT(Generic):
else: else:
raise TypeError('Expected None!') raise TypeError('Expected None!')
@staticmethod
def may_share_memory(a, b):
# None never share memory between object, in the sence of DebugMode.
# Python None are singleton
return False
none_type_t = NoneTypeT() none_type_t = NoneTypeT()
# This is a variable instance. It can be used only once per fgraph. # This is a variable instance. It can be used only once per fgraph.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论