From cd7d004f9927e6ec290ab87f635885502af83292 Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Sun, 15 Oct 2017 19:33:02 -0700 Subject: [PATCH 1/4] [FIX] Fix target warning --- python/tvm/target.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/tvm/target.py b/python/tvm/target.py index f55a2d613d05..98a422621a4f 100644 --- a/python/tvm/target.py +++ b/python/tvm/target.py @@ -88,6 +88,7 @@ def __init__(self, self.target_name = target_name self.options = _merge_opts([], options) self.device_name = "" + self._old_target = None # Parse device option for item in self.options: if item.startswith("-device="): @@ -125,11 +126,11 @@ def __repr__(self): return self.__str__() def __enter__(self): - self._old_target = Target.current if self._old_target is not None and str(self) != str(self._old_target): warnings.warn( "Override target '%s' with new target scope '%s'" % ( self._old_target, self)) + self._old_target = Target.current Target.current = self return self From 70c1cd1208edf9106884685f34d3d11e467f64cc Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Sun, 15 Oct 2017 19:47:30 -0700 Subject: [PATCH 2/4] [FIX] Deduplicate options --- python/tvm/target.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/tvm/target.py b/python/tvm/target.py index 98a422621a4f..2e30816bbb73 100644 --- a/python/tvm/target.py +++ b/python/tvm/target.py @@ -56,6 +56,7 @@ def _merge_opts(opts, new_opts): if isinstance(new_opts, str): new_opts = new_opts.split() if new_opts: + new_opts = [opt for opt in new_opts if opt not in opts] return opts + new_opts return opts @@ -88,7 +89,6 @@ def __init__(self, self.target_name = target_name self.options = _merge_opts([], options) self.device_name = "" - self._old_target = None # Parse device option for item in self.options: if item.startswith("-device="): @@ -126,11 +126,11 @@ def __repr__(self): return self.__str__() def __enter__(self): + self._old_target = Target.current if self._old_target is not None and str(self) != str(self._old_target): warnings.warn( "Override target '%s' with new target scope '%s'" % ( self._old_target, self)) - self._old_target = Target.current Target.current = self return self From b141fcac2b6e31c584cdab3bca1761aee7f79720 Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Mon, 16 Oct 2017 11:44:33 -0700 Subject: [PATCH 3/4] Fix --- python/tvm/target.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tvm/target.py b/python/tvm/target.py index 2e30816bbb73..59f55be9c6c8 100644 --- a/python/tvm/target.py +++ b/python/tvm/target.py @@ -56,7 +56,7 @@ def _merge_opts(opts, new_opts): if isinstance(new_opts, str): new_opts = new_opts.split() if new_opts: - new_opts = [opt for opt in new_opts if opt not in opts] + new_opts = [opt for opt in new_opts if opt not in set(opts)] return opts + new_opts return opts From 11fa65aa29552e2f6fb46d8c3118d996e70046fd Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Mon, 16 Oct 2017 12:49:17 -0700 Subject: [PATCH 4/4] Fix --- python/tvm/target.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/tvm/target.py b/python/tvm/target.py index 59f55be9c6c8..1bcd1de7d3d9 100644 --- a/python/tvm/target.py +++ b/python/tvm/target.py @@ -56,7 +56,8 @@ def _merge_opts(opts, new_opts): if isinstance(new_opts, str): new_opts = new_opts.split() if new_opts: - new_opts = [opt for opt in new_opts if opt not in set(opts)] + opt_set = set(opts) + new_opts = [opt for opt in new_opts if opt not in opt_set] return opts + new_opts return opts