Integrate in_fuison and history
@@ -16,7 +16,7 @@ from cupy import statistics
_thread_local = threading.local()
-_thread_local.in_fusion = False
+_thread_local.history = None
_kind_score = {
'b': 0,
@@ -753,16 +753,14 @@ class Fusion(object):
return '<Fusion \'{}\'>'.format(self.name)
def __call__(self, *args, **kwargs):
- if _thread_local.in_fusion:
+ if _thread_local.history:
return self.func(*args, **kwargs)
else:
- _thread_local.in_fusion = True
_thread_local.history = _FusionHistory()
try:
return self._call(*args, **kwargs)
finally:
- _thread_local.in_fusion = False
- del _thread_local.history
+ _thread_local.history = None
def compile(self, *args, **kwargs):
if builtins.any(
@@ -850,8 +848,7 @@ class ufunc(core.ufunc):
return repr(self._cupy_op)
def __call__(self, *args, **kwargs):
- in_fusion = getattr(_thread_local, 'in_fusion', False)
- if in_fusion:
+ if _thread_local.history:
if builtins.any(isinstance(_, FusionVarPython) for _ in args):
return _thread_local.history.call_ufunc(
self._fusion_op, args, kwargs)
