提交 9d69b63c 编写于 作者: K kuizhiqing 提交者: Wei Shengyu

fix ct singleton

上级 7cbc6952
...@@ -72,13 +72,14 @@ def get_roll_index(H, W, shifts, place): ...@@ -72,13 +72,14 @@ def get_roll_index(H, W, shifts, place):
index_bp = paddle.to_tensor(index_fp, dtype='int64', place=place) index_bp = paddle.to_tensor(index_fp, dtype='int64', place=place)
return [index_fp, index_bp] return [index_fp, index_bp]
def singleton(class_):
instances = {} def singleton(cls):
def getinstance(*args, **kwargs): def wrapper_singleton(*args, **kwargs):
if class_ not in instances: if not wrapper_singleton.instance:
instances[class_] = class_(*args, **kwargs) wrapper_singleton.instance = cls(*args, **kwargs)
return instances[class_] return wrapper_singleton.instance
return getinstance wrapper_singleton.instance = None
return wrapper_singleton
@singleton @singleton
class RollWrapperSingleton(): class RollWrapperSingleton():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册