From 8b1cd341755da8851b2d8962e042d04078b39442 Mon Sep 17 00:00:00 2001 From: archibate <1931127624@qq.com> Date: Wed, 14 Oct 2020 17:12:57 +0800 Subject: [PATCH 1/3] [Bug] [lang] Fix error when subscripting a dict --- python/taichi/lang/impl.py | 9 ++++----- python/taichi/lang/ndrange.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python/taichi/lang/impl.py b/python/taichi/lang/impl.py index 502da27fdd275..8ee8349321dd6 100644 --- a/python/taichi/lang/impl.py +++ b/python/taichi/lang/impl.py @@ -97,7 +97,7 @@ def subscript(value, *indices): if isinstance(value, np.ndarray): return value.__getitem__(*indices) - if isinstance(value, tuple) or isinstance(value, list): + if isinstance(value, (tuple, list, dict)): assert len(indices) == 1 return value[indices[0]] @@ -243,6 +243,7 @@ def layout(): for func in self.materialize_callbacks: func() + self.materialize_callbacks = [] def clear(self): if self.prog: @@ -535,11 +536,9 @@ def static(x, *xs): import types import taichi as ti if isinstance(x, (bool, int, float, range, list, tuple, enumerate, - ti.ndrange, ti.GroupedNDRange)) or x is None: - return x - elif isinstance(x, ti.lang.expr.Expr) and x.ptr.is_global_var(): + ti.ndrange, ti.GroupedNDRange, zip, filter, map)) or x is None: return x - elif isinstance(x, ti.Matrix) and x.is_global(): + elif isinstance(x, (ti.Expr, ti.Matrix)) and x.is_global(): return x elif isinstance(x, (types.FunctionType, types.MethodType)): return x diff --git a/python/taichi/lang/ndrange.py b/python/taichi/lang/ndrange.py index c23688f5ce717..0bc059d332100 100644 --- a/python/taichi/lang/ndrange.py +++ b/python/taichi/lang/ndrange.py @@ -3,7 +3,7 @@ def __init__(self, *args): args = list(args) for i in range(len(args)): if isinstance(args[i], list): - args[i] = list(args[i]) + args[i] = tuple(args[i]) if not isinstance(args[i], tuple): args[i] = (0, args[i]) assert len(args[i]) == 2 From 2238558e3aba2a7a383a0b547dd2c9c9645a9a57 Mon Sep 17 00:00:00 2001 From: Taichi Gardener Date: Wed, 14 Oct 2020 05:18:21 -0400 Subject: [PATCH 2/3] [skip ci] enforce code format --- python/taichi/lang/impl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/taichi/lang/impl.py b/python/taichi/lang/impl.py index 8ee8349321dd6..92b3a657f7895 100644 --- a/python/taichi/lang/impl.py +++ b/python/taichi/lang/impl.py @@ -535,8 +535,9 @@ def static(x, *xs): return [static(x)] + [static(x) for x in xs] import types import taichi as ti - if isinstance(x, (bool, int, float, range, list, tuple, enumerate, - ti.ndrange, ti.GroupedNDRange, zip, filter, map)) or x is None: + if isinstance(x, + (bool, int, float, range, list, tuple, enumerate, ti.ndrange, + ti.GroupedNDRange, zip, filter, map)) or x is None: return x elif isinstance(x, (ti.Expr, ti.Matrix)) and x.is_global(): return x From 4148044ee969dca56191b13f4d3170518907736b Mon Sep 17 00:00:00 2001 From: archibate <1931127624@qq.com> Date: Wed, 14 Oct 2020 20:30:19 +0800 Subject: [PATCH 3/3] trig build --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index a3f3f1df75bbd..930cfc557689a 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,6 @@ __pycache__ *.jpg *.egg-info .tlang_cache -.tidle_* /taichi/common/version.h /taichi/common/commit_hash.h /python/test_env