From 7c184742774f0a26264154d227208b6ffec3c76b Mon Sep 17 00:00:00 2001 From: archibate <1931127624@qq.com> Date: Thu, 25 Jun 2020 22:54:47 +0800 Subject: [PATCH] [lang] Deprecate ti.raw_pow --- python/taichi/lang/ops.py | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/python/taichi/lang/ops.py b/python/taichi/lang/ops.py index 7bcabaf869d72..0afd58d682759 100644 --- a/python/taichi/lang/ops.py +++ b/python/taichi/lang/ops.py @@ -207,42 +207,6 @@ def random(dt=None): return Expr(ti_core.make_rand_expr(dt)) -# TODO: move this to a C++ pass (#944) -def pow(self, power): - import taichi as ti - if not is_taichi_expr(self) and not is_taichi_expr(power): - # Python constant computations (#1188) - return raw_pow(self, power) - if not isinstance(power, int): - return raw_pow(self, power) - if power == 0: - # TODO: remove the hack, use {Expr,Matrix}.dup().fill(1) - # also note that this can be solved by #940 - return self * 0 + 1 - - negative = power < 0 - # Why not simply use `power = abs(power)`? - # Because `abs` is overrided by the `ti.abs` above. - if negative: - power = -power - - tmp = self - ret = None - while power: - if power & 1: - if ret is None: - ret = tmp - else: - ret = ti.expr_init(ret * tmp) - tmp = ti.expr_init(tmp * tmp) - power >>= 1 - - if negative: - return 1 / ret - else: - return ret - - # NEXT: add matpow(self, power) @@ -280,7 +244,7 @@ def expr_python_mod(a, b): @binary -def raw_pow(a, b): +def pow(a, b): return _binary_operation(ti_core.expr_pow, ops.pow, a, b)