Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Remove a.atomic(b) #7925

Merged
merged 4 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions python/taichi/lang/common_ops.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import warnings

from taichi.lang import ops
from taichi.lang.util import in_python_scope
from taichi.types import primitive_types
from typing import TYPE_CHECKING


class TaichiOperations:
"""The base class of taichi operations of expressions. Subclasses: :class:`~taichi.lang.expr.Expr`, :class:`~taichi.lang.matrix.Matrix`"""

__deprecated_atomic_ops__ = {
"atomic_add": "_atomic_add",
"atomic_mul": "_atomic_mul",
"atomic_and": "_atomic_and",
"atomic_or": "_atomic_or",
"atomic_sub": "_atomic_sub",
"atomic_xor": "_atomic_xor",
}

def __getattr__(self, item):
if item in TaichiOperations.__deprecated_atomic_ops__:
warnings.warn(
f"a.{item}(b) is deprecated, and it will be removed in Taichi v1.6.0. Please use ti.{item}(a, b) instead.",
DeprecationWarning,
)
return getattr(self, TaichiOperations.__deprecated_atomic_ops__[item])
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{item}'")
if TYPE_CHECKING:
# Make pylint happy
def __getattr__(self, item):
pass

def __neg__(self):
return ops.neg(self)
Expand Down
15 changes: 0 additions & 15 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@
from tests import test_utils


@test_utils.test()
def test_deprecate_a_atomic_b():
with pytest.warns(
DeprecationWarning,
match=r"a\.atomic_add\(b\) is deprecated, and it will be removed in Taichi v1.6.0.",
):

@ti.kernel
def func():
a = 1
a.atomic_add(2)

func()


@test_utils.test()
def test_deprecate_element_shape_scalar():
with pytest.warns(
Expand Down