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

[Error] Raise errors when using metal sparse #7113

Merged
merged 6 commits into from
Jan 11, 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
14 changes: 5 additions & 9 deletions python/taichi/_snode/fields_builder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from typing import Any, Optional, Sequence, Union

from taichi._lib import core as _ti_core
Expand Down Expand Up @@ -76,9 +75,8 @@ def pointer(self, indices: Union[Sequence[_Axis], _Axis],
dimensions: Union[Sequence[int], int]):
"""Same as :func:`taichi.lang.snode.SNode.pointer`"""
if impl.current_cfg().arch == _ti_core.metal:
warnings.warn(
"Pointer SNode on metal backend is deprecated, and it will be removed in v1.4.0.",
DeprecationWarning)
raise TaichiRuntimeError(
"Pointer SNode on metal backend is deprecated and removed.")
self._check_not_finalized()
self.empty = False
return self.root.pointer(indices, dimensions)
Expand All @@ -94,8 +92,7 @@ def dynamic(self,
"""Same as :func:`taichi.lang.snode.SNode.dynamic`"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Dynamic SNode on metal backend is deprecated and removed in this release."
)
"Dynamic SNode on metal backend is deprecated and removed.")
self._check_not_finalized()
self.empty = False
return self.root.dynamic(index, dimension, chunk_size)
Expand All @@ -104,9 +101,8 @@ def bitmasked(self, indices: Union[Sequence[_Axis], _Axis],
dimensions: Union[Sequence[int], int]):
"""Same as :func:`taichi.lang.snode.SNode.bitmasked`"""
if impl.current_cfg().arch == _ti_core.metal:
warnings.warn(
"Bitmasked SNode on metal backend is deprecated, and it will be removed in v1.4.0.",
DeprecationWarning)
raise TaichiRuntimeError(
"Bitmasked SNode on metal backend is deprecated and removed.")
self._check_not_finalized()
self.empty = False
return self.root.bitmasked(indices, dimensions)
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/examples/features/sparse/taichi_bitmasked.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import taichi as ti

ti.init(arch=ti.gpu)
ti.init(arch=ti.cuda)

n = 256
x = ti.field(ti.f32)
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/examples/simulation/comet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import taichi as ti

ti.init(arch=[ti.cuda, ti.metal])
ti.init(arch=ti.cuda)

dim = 3
N = 1024 * 8
Expand Down
17 changes: 7 additions & 10 deletions python/taichi/lang/snode.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numbers
import warnings

from taichi._lib import core as _ti_core
from taichi.lang import expr, impl, matrix
from taichi.lang.exception import TaichiRuntimeError
from taichi.lang.field import BitpackedFields, Field
from taichi.lang.util import get_traceback

Expand Down Expand Up @@ -49,9 +49,8 @@ def pointer(self, axes, dimensions):
The added :class:`~taichi.lang.SNode` instance.
"""
if impl.current_cfg().arch == _ti_core.metal:
warnings.warn(
"Pointer SNode on metal backend is deprecated, and it will be removed in v1.4.0.",
DeprecationWarning)
raise TaichiRuntimeError(
"Pointer SNode on metal backend is deprecated and removed.")
if isinstance(dimensions, numbers.Number):
dimensions = [dimensions] * len(axes)
return SNode(
Expand Down Expand Up @@ -80,9 +79,8 @@ def dynamic(self, axis, dimension, chunk_size=None):
The added :class:`~taichi.lang.SNode` instance.
"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiCompilationError(
"Dynamic SNode on metal backend is deprecated and removed in this release."
)
raise TaichiRuntimeError(
"Dynamic SNode on metal backend is deprecated and removed.")
assert len(axis) == 1
if chunk_size is None:
chunk_size = dimension
Expand All @@ -101,9 +99,8 @@ def bitmasked(self, axes, dimensions):
The added :class:`~taichi.lang.SNode` instance.
"""
if impl.current_cfg().arch == _ti_core.metal:
warnings.warn(
"Bitmasked SNode on metal backend is deprecated, and it will be removed in v1.4.0.",
DeprecationWarning)
raise TaichiRuntimeError(
"Bitmasked SNode on metal backend is deprecated and removed.")
if isinstance(dimensions, numbers.Number):
dimensions = [dimensions] * len(axes)
return SNode(
Expand Down
24 changes: 10 additions & 14 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,22 @@ def test_deprecate_element_shape_ndarray_arg():
element_shape=(1, ))


# Remove this before v1.5.0
@test_utils.test(arch=ti.metal)
def test_deprecate_metal_sparse():
with pytest.warns(
DeprecationWarning,
match=
"Pointer SNode on metal backend is deprecated, and it will be removed in v1.4.0."
):
a = ti.root.pointer(ti.i, 10)
with pytest.warns(
DeprecationWarning,
match=
"Bitmasked SNode on metal backend is deprecated, and it will be removed in v1.4.0."
with pytest.raises(
ti.TaichiRuntimeError,
match="Pointer SNode on metal backend is deprecated and removed."):
ti.root.pointer(ti.i, 10)
with pytest.raises(
ti.TaichiRuntimeError,
match="Bitmasked SNode on metal backend is deprecated and removed."
):
b = a.bitmasked(ti.j, 10)
ti.root.bitmasked(ti.j, 10)

with pytest.raises(
ti.TaichiRuntimeError,
match=
"Dynamic SNode on metal backend is deprecated and removed in this release."
):
match="Dynamic SNode on metal backend is deprecated and removed."):
ti.root.dynamic(ti.i, 10)


Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def test_matrix_field_dynamic_index_different_path_length():
assert v._get_dynamic_index_stride() is None


@test_utils.test()
@test_utils.test(require=ti.extension.sparse, exclude=[ti.metal])
def test_matrix_field_dynamic_index_not_pure_dense():
v = ti.Vector.field(2, ti.i32)
x = v.get_scalar_field(0)
Expand Down