You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by wu...@apache.org on 2021/12/20 03:33:19 UTC

[tvm] branch main updated: Fix GLOBAL_SCOPE Shallow copy bug (#9718)

This is an automated email from the ASF dual-hosted git repository.

wuwei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 5cb5c5b  Fix GLOBAL_SCOPE Shallow copy bug (#9718)
5cb5c5b is described below

commit 5cb5c5bda7976666da9c9f862654cbbfabadc69f
Author: pansn1995 <62...@users.noreply.github.com>
AuthorDate: Mon Dec 20 11:32:55 2021 +0800

    Fix GLOBAL_SCOPE Shallow copy bug (#9718)
---
 python/tvm/autotvm/env.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/python/tvm/autotvm/env.py b/python/tvm/autotvm/env.py
index 33073d3..28e3dca 100644
--- a/python/tvm/autotvm/env.py
+++ b/python/tvm/autotvm/env.py
@@ -18,6 +18,8 @@
 
 
 class AutotvmGlobalScope(object):
+    """The global autotvm scope."""
+
     current = None
 
     def __init__(self):
@@ -27,6 +29,13 @@ class AutotvmGlobalScope(object):
         self.in_tuning = False
         self.silent = False
 
+    def deep_copy(self, global_scope):
+        """Deep copy from another instance of AutotvmGlobalScope."""
+        self._old = AutotvmGlobalScope.current
+
+        self.in_tuning = global_scope.in_tuning
+        self.silent = global_scope.silent
+
 
 GLOBAL_SCOPE = AutotvmGlobalScope()
 
@@ -34,5 +43,5 @@ GLOBAL_SCOPE = AutotvmGlobalScope()
 def reset_global_scope(global_scope):
     """Reset global autotvm state. This is needed to initialize PopenPool workers."""
     global GLOBAL_SCOPE
-    GLOBAL_SCOPE = global_scope
+    GLOBAL_SCOPE.deep_copy(global_scope)
     AutotvmGlobalScope.current = global_scope