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] Deprecate ti.experimental.real_func #8409

Merged
merged 3 commits into from
Nov 17, 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
2 changes: 1 addition & 1 deletion python/taichi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from taichi.types.primitive_types import *


from taichi import ad, algorithms, graph, linalg, math, sparse, tools, types
from taichi import ad, algorithms, experimental, graph, linalg, math, sparse, tools, types
from taichi.ui import GUI, hex_to_rgb, rgb_to_hex, ui

# Issue#2223: Do not reorder, or we're busted with partially initialized module
Expand Down
13 changes: 13 additions & 0 deletions python/taichi/experimental.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from taichi.lang.kernel_impl import real_func as _real_func
import warnings


def real_func(func):
warnings.warn(
"ti.experimental.real_func is deprecated because it is no longer experimental. " "Use ti.real_func instead.",
DeprecationWarning,
)
return _real_func(func)


__all__ = ["real_func"]
1 change: 1 addition & 0 deletions tests/python/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _get_expected_matrix_apis():
"dx12",
"eig",
"exp",
"experimental",
"extension",
"f16",
"f32",
Expand Down
25 changes: 25 additions & 0 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,28 @@ def test_deprecate_initialization_of_scene():
match=r"Instantiating ti.ui.Scene directly is deprecated, use the get_scene\(\) function from a taichi.ui.Window object instead.",
):
ti.ui.Scene()


@test_utils.test(arch=[ti.cpu, ti.cuda])
def test_deprecate_experimental_real_func():
with pytest.warns(
DeprecationWarning,
match="ti.experimental.real_func is deprecated because it is no longer experimental. "
"Use ti.real_func instead.",
):

@ti.experimental.real_func
def foo(a: ti.i32) -> ti.i32:
s = 0
for i in range(100):
if i == a + 1:
return s
s = s + i
return s

@ti.kernel
def bar(a: ti.i32) -> ti.i32:
return foo(a)

assert bar(10) == 11 * 5
assert bar(200) == 99 * 50
Loading