diff --git a/python/taichi/__init__.py b/python/taichi/__init__.py index a6f6bf06148fa..034052ed5bd73 100644 --- a/python/taichi/__init__.py +++ b/python/taichi/__init__.py @@ -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 diff --git a/python/taichi/experimental.py b/python/taichi/experimental.py new file mode 100644 index 0000000000000..37fe5cefdc96a --- /dev/null +++ b/python/taichi/experimental.py @@ -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"] diff --git a/tests/python/test_api.py b/tests/python/test_api.py index 9c42ed0992274..38477b14c84c4 100644 --- a/tests/python/test_api.py +++ b/tests/python/test_api.py @@ -129,6 +129,7 @@ def _get_expected_matrix_apis(): "dx12", "eig", "exp", + "experimental", "extension", "f16", "f32", diff --git a/tests/python/test_deprecation.py b/tests/python/test_deprecation.py index b1dd882f970c7..9ad4cc1e7eeff 100644 --- a/tests/python/test_deprecation.py +++ b/tests/python/test_deprecation.py @@ -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