diff --git a/tests/python/test_ad_gdar_diffmpm.py b/tests/python/test_ad_gdar_diffmpm.py index a4001a58e085a..d30bad5834d61 100644 --- a/tests/python/test_ad_gdar_diffmpm.py +++ b/tests/python/test_ad_gdar_diffmpm.py @@ -4,7 +4,8 @@ from tests import test_utils -def _test_gdar_mpm(): +@test_utils.test(require=ti.extension.assertion, debug=True, exclude=[ti.cc]) +def test_gdar_mpm(): real = ti.f32 dim = 2 @@ -182,17 +183,3 @@ def substep(s): learning_rate = 10 init_v[None][0] -= learning_rate * grad[0] init_v[None][1] -= learning_rate * grad[1] - - -@test_utils.test(require=ti.extension.assertion, debug=True, exclude=[ti.cc]) -def test_gdar_mpm(): - _test_gdar_mpm() - - -@test_utils.test(require=ti.extension.assertion, - debug=True, - exclude=[ti.cc], - real_matrix=True, - real_matrix_scalarize=True) -def test_gdar_mpm_real_matrix_scalarize(): - _test_gdar_mpm() diff --git a/tests/python/test_ast_refactor.py b/tests/python/test_ast_refactor.py index 78ab68c8d0585..3eeadc180d596 100644 --- a/tests/python/test_ast_refactor.py +++ b/tests/python/test_ast_refactor.py @@ -432,7 +432,8 @@ def func(): assert x[i, j, k] == 0 -def _test_grouped_ndrange_for(): +@test_utils.test(print_preprocessed_ir=True) +def test_grouped_ndrange_for(): x = ti.field(ti.i32, shape=(6, 6, 6)) y = ti.field(ti.i32, shape=(6, 6, 6)) @@ -457,18 +458,6 @@ def func(): assert x[i, j, k] == y[i, j, k] -@test_utils.test(print_preprocessed_ir=True) -def test_grouped_ndrange_for(): - _test_grouped_ndrange_for() - - -@test_utils.test(print_preprocessed_ir=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_grouped_ndrange_for_matrix_scalarize(): - _test_grouped_ndrange_for() - - @test_utils.test(print_preprocessed_ir=True) def test_static_for_break(): n = 10 @@ -493,7 +482,8 @@ def foo(a: ti.template()): assert a[i] == 0 -def _test_static_grouped_for_break(): +@test_utils.test(print_preprocessed_ir=True) +def test_static_grouped_for_break(): n = 4 @ti.kernel @@ -517,18 +507,6 @@ def foo(a: ti.template()): assert a[i, j] == 0 -@test_utils.test(print_preprocessed_ir=True) -def test_static_grouped_for_break(): - _test_static_grouped_for_break() - - -@test_utils.test(print_preprocessed_ir=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_static_grouped_for_break_matrix_scalarize(): - _test_static_grouped_for_break() - - @test_utils.test(print_preprocessed_ir=True) def test_static_for_continue(): n = 10 @@ -551,7 +529,8 @@ def foo(a: ti.template()): assert a[i] == 3 -def _test_static_grouped_for_continue(): +@test_utils.test(print_preprocessed_ir=True) +def test_static_grouped_for_continue(): n = 4 @ti.kernel @@ -573,18 +552,6 @@ def foo(a: ti.template()): assert a[i, j] == 3 -@test_utils.test(print_preprocessed_ir=True) -def test_static_grouped_for_continue(): - _test_static_grouped_for_continue() - - -@test_utils.test(print_preprocessed_ir=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_static_grouped_for_continue_matrix_scalarize(): - _test_static_grouped_for_continue() - - @test_utils.test(print_preprocessed_ir=True) def test_for_break(): n = 4 @@ -885,8 +852,8 @@ def foo(x: ti.template()) -> ti.i32: foo(2) -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_single_listcomp_matrix_scalarize(): +@test_utils.test() +def test_single_listcomp(): @ti.func def identity(dt, n: ti.template()): return ti.Matrix([[ti.cast(int(i == j), dt) for j in range(n)] @@ -904,7 +871,8 @@ def foo(n: ti.template()) -> ti.i32: assert foo(5) == 1 -def _test_listcomp(): +@test_utils.test() +def test_listcomp(): @ti.func def identity(dt, n: ti.template()): return ti.Matrix([[ti.cast(int(i == j), dt) for j in range(n)] @@ -923,16 +891,6 @@ def foo(n: ti.template()) -> ti.i32: assert foo(5) == 1 + 4 + 9 + 16 -@test_utils.test() -def test_listcomp(): - _test_listcomp() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_listcomp_matrix_scalarize(): - _test_listcomp() - - @test_utils.test() def test_dictcomp(): @ti.kernel @@ -1061,7 +1019,8 @@ def foo() -> ti.i32: assert foo() == 123 -def _test_grouped_static_for_cast(): +@test_utils.test() +def test_grouped_static_for_cast(): @ti.kernel def foo() -> ti.f32: ret = 0. @@ -1071,13 +1030,3 @@ def foo() -> ti.f32: return ret assert foo() == test_utils.approx(10) - - -@test_utils.test() -def test_grouped_static_for_cast(): - _test_grouped_static_for_cast() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_grouped_static_for_cast_matrix_scalarize(): - _test_grouped_static_for_cast() diff --git a/tests/python/test_bls.py b/tests/python/test_bls.py index 9e7de99d733d5..b4116bbf01633 100644 --- a/tests/python/test_bls.py +++ b/tests/python/test_bls.py @@ -62,142 +62,54 @@ def _test_bls_stencil(*args, **kwargs): bls_test_template(*args, **kwargs) -def _test_gather_1d_trivial(): +@test_utils.test(require=ti.extension.bls) +def test_gather_1d_trivial(): # y[i] = x[i] _test_bls_stencil(1, 128, bs=32, stencil=((0, ), )) -def _test_gather_1d(): +@test_utils.test(require=ti.extension.bls) +def test_gather_1d(): # y[i] = x[i - 1] + x[i] _test_bls_stencil(1, 128, bs=32, stencil=((-1, ), (0, ))) -def _test_gather_2d(): +@test_utils.test(require=ti.extension.bls) +def test_gather_2d(): stencil = [(0, 0), (0, -1), (0, 1), (1, 0)] _test_bls_stencil(2, 128, bs=16, stencil=stencil) -def _test_gather_2d_nonsquare(): +@test_utils.test(require=ti.extension.bls) +def test_gather_2d_nonsquare(): stencil = [(0, 0), (0, -1), (0, 1), (1, 0)] _test_bls_stencil(2, 128, bs=(4, 16), stencil=stencil) -def _test_gather_3d(): +@test_utils.test(require=ti.extension.bls) +def test_gather_3d(): stencil = [(-1, -1, -1), (2, 0, 1)] _test_bls_stencil(3, 64, bs=(4, 8, 16), stencil=stencil) -def _test_scatter_1d_trivial(): +@test_utils.test(require=ti.extension.bls) +def test_scatter_1d_trivial(): # y[i] = x[i] _test_bls_stencil(1, 128, bs=32, stencil=((0, ), ), scatter=True) -def _test_scatter_1d(): +@test_utils.test(require=ti.extension.bls) +def test_scatter_1d(): _test_bls_stencil(1, 128, bs=32, stencil=( (1, ), (0, ), ), scatter=True) -def _test_scatter_2d(): - stencil = [(0, 0), (0, -1), (0, 1), (1, 0)] - _test_bls_stencil(2, 128, bs=16, stencil=stencil, scatter=True) - - -@test_utils.test(require=ti.extension.bls) -def test_gather_1d_trivial(): - _test_gather_1d_trivial() - - -@test_utils.test(require=ti.extension.bls) -def test_gather_1d(): - _test_gather_1d() - - -@test_utils.test(require=ti.extension.bls) -def test_gather_2d(): - _test_gather_2d() - - -@test_utils.test(require=ti.extension.bls) -def test_gather_2d_nonsquare(): - _test_gather_2d_nonsquare() - - -@test_utils.test(require=ti.extension.bls) -def test_gather_3d(): - _test_gather_3d() - - -@test_utils.test(require=ti.extension.bls) -def test_scatter_1d_trivial(): - _test_scatter_1d_trivial() - - -@test_utils.test(require=ti.extension.bls) -def test_scatter_1d(): - _test_scatter_1d() - - @test_utils.test(require=ti.extension.bls) def test_scatter_2d(): - _test_scatter_2d() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gather_1d_trivial_matrix_scalarize(): - _test_gather_1d_trivial() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gather_1d_matrix_scalarize(): - _test_gather_1d() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gather_2d_matrix_scalarize(): - _test_gather_2d() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gather_2d_nonsquare_matrix_scalarize(): - _test_gather_2d_nonsquare() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gather_3d_matrix_scalarize(): - _test_gather_3d() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_scatter_1d_trivial_matrix_scalarize(): - _test_scatter_1d_trivial() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_scatter_1d_matrix_scalarize(): - _test_scatter_1d() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_scatter_2d_matrix_scalarize(): - _test_scatter_2d() + stencil = [(0, 0), (0, -1), (0, 1), (1, 0)] + _test_bls_stencil(2, 128, bs=16, stencil=stencil, scatter=True) @test_utils.test(require=ti.extension.bls) diff --git a/tests/python/test_bls_assume_in_range.py b/tests/python/test_bls_assume_in_range.py index 0e98c659a677f..c7dc0cbe3ceab 100644 --- a/tests/python/test_bls_assume_in_range.py +++ b/tests/python/test_bls_assume_in_range.py @@ -4,7 +4,8 @@ from .bls_test_template import bls_particle_grid -def _test_scattering(): +@test_utils.test(require=ti.extension.bls) +def test_scattering(): bls_particle_grid(N=128, ppc=10, block_size=8, @@ -12,7 +13,8 @@ def _test_scattering(): use_offset=False) -def _test_scattering_offset(): +@test_utils.test(require=ti.extension.bls) +def test_scattering_offset(): bls_particle_grid(N=128, ppc=10, block_size=8, @@ -20,7 +22,8 @@ def _test_scattering_offset(): use_offset=True) -def _test_scattering_two_pointer_levels(): +@test_utils.test(require=ti.extension.bls) +def test_scattering_two_pointer_levels(): bls_particle_grid(N=128, ppc=10, block_size=8, @@ -29,7 +32,8 @@ def _test_scattering_two_pointer_levels(): use_offset=False) -def _test_gathering(): +@test_utils.test(require=ti.extension.bls) +def test_gathering(): bls_particle_grid(N=128, ppc=10, block_size=8, @@ -37,7 +41,8 @@ def _test_gathering(): use_offset=False) -def _test_gathering_offset(): +@test_utils.test(require=ti.extension.bls) +def test_gathering_offset(): bls_particle_grid(N=128, ppc=10, block_size=8, @@ -45,64 +50,4 @@ def _test_gathering_offset(): use_offset=True) -@test_utils.test(require=ti.extension.bls) -def test_gathering(): - _test_gathering() - - -@test_utils.test(require=ti.extension.bls) -def test_gathering_offset(): - _test_gathering_offset() - - -@test_utils.test(require=ti.extension.bls) -def test_scattering_two_pointer_levels(): - _test_scattering_two_pointer_levels() - - -@test_utils.test(require=ti.extension.bls) -def test_scattering(): - _test_scattering() - - -@test_utils.test(require=ti.extension.bls) -def test_scattering_offset(): - _test_scattering_offset() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gathering_matrix_scalarize(): - _test_gathering() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_gathering_offset_matrix_scalarize(): - _test_gathering_offset() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_scattering_matrix_scalarize(): - _test_scattering() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_scattering_offset_matrix_scalarize(): - _test_scattering_offset() - - -@test_utils.test(require=ti.extension.bls, - real_matrix=True, - real_matrix_scalarize=True) -def test_scattering_two_pointer_levels_matrix_scalarize(): - _test_scattering_two_pointer_levels() - - # TODO: debug mode behavior of assume_in_range diff --git a/tests/python/test_custom_struct.py b/tests/python/test_custom_struct.py index 094b2987dafa6..185bc759c9d04 100644 --- a/tests/python/test_custom_struct.py +++ b/tests/python/test_custom_struct.py @@ -78,7 +78,8 @@ def run_python_scope(): assert y[i].b == int(1.01 * i) -def _test_struct_fill(): +@test_utils.test() +def test_struct_fill(): n = 32 # also tests implicit cast @@ -114,16 +115,6 @@ def fill_elements(): assert np.allclose(x[i].b.to_numpy(), int(x[i].a)) -@test_utils.test() -def test_struct_fill(): - _test_struct_fill() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_struct_fill_matrix_scalarize(): - _test_struct_fill() - - @test_utils.test() def test_matrix_type(): n = 32 @@ -152,7 +143,8 @@ def run_python_scope(): assert np.allclose(x[i].to_numpy(), np.array([i + 1, i, i])) -def _test_struct_type(): +@test_utils.test() +def test_struct_type(): n = 32 vec3f = ti.types.vector(3, float) line3f = ti.types.struct(linedir=vec3f, length=float) @@ -213,16 +205,6 @@ def run_python_scope(): assert x[i].line.length == 5.0 -@test_utils.test() -def test_struct_type(): - _test_struct_type() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_struct_type_matrix_scalarize(): - _test_struct_type() - - @test_utils.test(exclude=ti.cc) def test_dataclass(): # example struct class type @@ -264,7 +246,8 @@ def get_area_field() -> ti.f32: assert np.isclose(get_area_field(), 4.0 * 3.14 * 4.0) -def _test_struct_assign(): +@test_utils.test() +def test_struct_assign(): n = 32 vec3f = ti.types.vector(3, float) line3f = ti.types.struct(linedir=vec3f, length=float) @@ -302,16 +285,6 @@ def run_python_scope(): assert x[i].line.length == i + 0.5 -@test_utils.test() -def test_struct_assign(): - _test_struct_assign() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_struct_assign_matrix_scalarize(): - _test_struct_assign() - - @test_utils.test() def test_compound_type_implicit_cast(): vec2i = ti.types.vector(2, int) diff --git a/tests/python/test_dynamic.py b/tests/python/test_dynamic.py index 5b7f3febf6b2d..bfdf96e7a91e1 100644 --- a/tests/python/test_dynamic.py +++ b/tests/python/test_dynamic.py @@ -266,7 +266,8 @@ def make_list(): assert x[i, j].d == i * j * 10000000000 -def _test_append_matrix(): +@test_utils.test(require=ti.extension.sparse, exclude=[ti.metal]) +def test_append_matrix(): mat = ti.types.matrix(n=2, m=2, dtype=ti.u8) f = mat.field() pixel = ti.root.dense(ti.i, 10).dynamic(ti.j, 20, 4) @@ -289,19 +290,7 @@ def make_list(): @test_utils.test(require=ti.extension.sparse, exclude=[ti.metal]) -def test_append_matrix(): - _test_append_matrix() - - -@test_utils.test(require=ti.extension.sparse, - exclude=[ti.metal], - real_matrix=True, - real_matrix_scalarize=True) -def test_append_matrix_real_matrix(): - _test_append_matrix() - - -def _test_append_matrix_in_struct(): +def test_append_matrix_in_struct(): mat = ti.types.matrix(n=2, m=2, dtype=ti.u8) struct = ti.types.struct(a=ti.u64, b=mat, c=ti.u16) f = struct.field() @@ -326,16 +315,3 @@ def make_list(): for k in range(4): assert f[i, j].b[k // 2, k % 2] == i * j * (k + 1) % 256 assert f[i, j].c == i * j * 5000 % 65536 - - -@test_utils.test(require=ti.extension.sparse, exclude=[ti.metal]) -def test_append_matrix_in_struct(): - _test_append_matrix_in_struct() - - -@test_utils.test(require=ti.extension.sparse, - exclude=[ti.metal], - real_matrix=True, - real_matrix_scalarize=True) -def test_append_matrix_in_struct_matrix_scalarize(): - _test_append_matrix_in_struct() diff --git a/tests/python/test_eig.py b/tests/python/test_eig.py index 4ca077574b15a..6a76eef4fb2dd 100644 --- a/tests/python/test_eig.py +++ b/tests/python/test_eig.py @@ -175,58 +175,3 @@ def test_sym_eig3x3_f32(a00): fast_math=False) def test_sym_eig3x3_f64(a00): _test_sym_eig3x3(ti.f64, a00) - - -@pytest.mark.parametrize("func", [_test_eig2x2_real, _test_eig2x2_complex]) -@test_utils.test(default_fp=ti.f32, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_eig2x2_f32_real_matrix_scalarize(func): - func(ti.f32) - - -@pytest.mark.parametrize("func", [_test_eig2x2_real, _test_eig2x2_complex]) -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_eig2x2_f64_real_matrix_scalarize(func): - func(ti.f64) - - -@test_utils.test(default_fp=ti.f32, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_sym_eig2x2_f32_real_matrix_scalarize(): - _test_sym_eig2x2(ti.f32) - - -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_sym_eig2x2_f64_real_matrix_scalarize(): - _test_sym_eig2x2(ti.f64) - - -@pytest.mark.parametrize('a00', [i for i in range(10)]) -@test_utils.test(default_fp=ti.f32, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_sym_eig3x3_f32_real_matrix_scalarize(a00): - _test_sym_eig3x3(ti.f32, a00) - - -@pytest.mark.parametrize('a00', [i for i in range(10)]) -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_sym_eig3x3_f64_real_matrix_scalarize(a00): - _test_sym_eig3x3(ti.f64, a00) diff --git a/tests/python/test_element_wise.py b/tests/python/test_element_wise.py index f561afa449f65..cecbccc9fb6b6 100644 --- a/tests/python/test_element_wise.py +++ b/tests/python/test_element_wise.py @@ -300,7 +300,11 @@ def func(): assert test_utils.allclose(xf[14], np.round(yf), rel=1e-5) -def _test_ternary_i(is_mat): +@pytest.mark.parametrize('is_mat', [(True, True, True), (True, False, False), + (False, True, False), (False, False, True), + (False, True, True)]) +@test_utils.test() +def test_ternary_i(is_mat): cond_is_mat, lhs_is_mat, rhs_is_mat = is_mat x = ti.Matrix.field(3, 2, ti.i32, 1) if cond_is_mat: @@ -341,19 +345,3 @@ def func(): assert test_utils.allclose( x[0], np.int32(np.bool_(y)) * z + np.int32(1 - np.bool_(y)) * w) - - -@pytest.mark.parametrize('is_mat', [(True, True, True), (True, False, False), - (False, True, False), (False, False, True), - (False, True, True)]) -@test_utils.test() -def test_ternary_i(is_mat): - _test_ternary_i(is_mat) - - -@pytest.mark.parametrize('is_mat', [(True, True, True), (True, False, False), - (False, True, False), (False, False, True), - (False, True, True)]) -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_ternary_i_matrix_scalarize(is_mat): - _test_ternary_i(is_mat) diff --git a/tests/python/test_function.py b/tests/python/test_function.py index fb3d37fe9aa80..e5e6169626e3a 100644 --- a/tests/python/test_function.py +++ b/tests/python/test_function.py @@ -361,7 +361,8 @@ def bar(): bar() -def _test_func_ndarray_arg(): +@test_utils.test(arch=[ti.cpu, ti.cuda], debug=True) +def test_func_ndarray_arg(): vec3 = ti.types.vector(3, ti.f32) @ti.func @@ -392,20 +393,8 @@ def test_error(x: ti.types.ndarray(ndim=1)): test_error(arr) -@test_utils.test(arch=[ti.cpu, ti.cuda], debug=True) -def test_func_ndarray_arg(): - _test_func_ndarray_arg() - - -@test_utils.test(arch=[ti.cpu, ti.cuda], - debug=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_func_ndarray_arg_matrix_scalarize(): - _test_func_ndarray_arg() - - -def _test_func_matrix_arg(): +@test_utils.test(debug=True) +def test_func_matrix_arg(): vec3 = ti.types.vector(3, ti.f32) @ti.func @@ -423,7 +412,8 @@ def test_k(): test_k() -def _test_func_matrix_arg_with_error(): +@test_utils.test() +def test_func_matrix_arg_with_error(): vec3 = ti.types.vector(3, ti.f32) @ti.func @@ -441,21 +431,8 @@ def test_error(): test_error() -@test_utils.test(arch=[ti.cpu, ti.cuda], debug=True) -def test_func_matrix_arg(): - _test_func_matrix_arg() - _test_func_matrix_arg_with_error() - - -@test_utils.test(arch=[ti.cpu, ti.cuda], - debug=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_func_matrix_arg_real_matrix(): - _test_func_matrix_arg() - - -def _test_real_func_matrix_arg(): +@test_utils.test(arch=[ti.cpu, ti.cuda]) +def test_real_func_matrix_arg(): @ti.experimental.real_func def mat_arg(a: ti.math.mat2, b: ti.math.vec2) -> float: return a[0, 0] + a[0, 1] + a[1, 0] + a[1, 1] + b[0] + b[1] @@ -472,18 +449,6 @@ def foo() -> float: assert foo() == pytest.approx(21) -@test_utils.test(arch=[ti.cpu, ti.cuda]) -def test_real_func_matrix_arg(): - _test_real_func_matrix_arg() - - -@test_utils.test(arch=[ti.cpu, ti.cuda], - real_matrix=True, - real_matrix_scalarize=True) -def test_real_func_matrix_arg_real_matrix(): - _test_real_func_matrix_arg() - - @test_utils.test(arch=[ti.cpu, ti.cuda]) def test_real_func_struct_ret(): s = ti.types.struct(a=ti.i16, b=ti.f64) @@ -500,7 +465,8 @@ def foo() -> ti.f64: assert foo() == pytest.approx(123 * 1.2345e300) -def _test_real_func_struct_ret_with_matrix(): +@test_utils.test(arch=[ti.cpu, ti.cuda]) +def test_real_func_struct_ret_with_matrix(): s0 = ti.types.struct(a=ti.math.vec3, b=ti.i16) s1 = ti.types.struct(a=ti.f32, b=s0) @@ -514,15 +480,3 @@ def foo() -> ti.f32: return s.a + s.b.a[0] + s.b.a[1] + s.b.a[2] + s.b.b assert foo() == pytest.approx(105.2) - - -@test_utils.test(arch=[ti.cpu, ti.cuda]) -def test_real_func_struct_ret_with_matrix(): - _test_real_func_struct_ret_with_matrix() - - -@test_utils.test(arch=[ti.cpu, ti.cuda], - real_matrix=True, - real_matrix_scalarize=True) -def test_real_func_struct_ret_with_matrix_real_matrix(): - _test_real_func_struct_ret_with_matrix() diff --git a/tests/python/test_ggui.py b/tests/python/test_ggui.py index fbefe57582949..64ed46a3367a0 100644 --- a/tests/python/test_ggui.py +++ b/tests/python/test_ggui.py @@ -360,7 +360,9 @@ def test_get_camera_view_and_projection_matrix(): assert (abs(projection_matrix[3, 2] - 1.0001000e-1) <= 1e-5) -def _test_fetching_color_attachment(): +@pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available") +@test_utils.test(arch=supported_archs) +def test_fetching_color_attachment(): window = ti.ui.Window('test', (640, 480), show_window=False) canvas = window.get_canvas() @@ -386,20 +388,6 @@ def render(): window.destroy() -@pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available") -@test_utils.test(arch=supported_archs) -def test_fetching_color_attachment(): - _test_fetching_color_attachment() - - -@pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available") -@test_utils.test(arch=supported_archs, - real_matrix=True, - real_matrix_scalarize=True) -def test_fetching_color_attachment_matrix_scalarize(): - _test_fetching_color_attachment() - - @pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available") @test_utils.test(arch=supported_archs, exclude=[(ti.vulkan, "Darwin")]) def test_fetching_depth_attachment(): diff --git a/tests/python/test_grouped.py b/tests/python/test_grouped.py index d82b0fd19cb67..0757c7f921814 100644 --- a/tests/python/test_grouped.py +++ b/tests/python/test_grouped.py @@ -2,7 +2,8 @@ from tests import test_utils -def _test_vector_index(): +@test_utils.test() +def test_vector_index(): val = ti.field(ti.i32) n = 4 @@ -27,16 +28,6 @@ def test(): assert val[i, j, k] == i + j * 2 + k * 3 -@test_utils.test() -def test_vector_index(): - _test_vector_index() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_vector_index_matrix_scalarize(): - _test_vector_index() - - @test_utils.test() def test_grouped(): val = ti.field(ti.i32) @@ -60,7 +51,8 @@ def test(): assert val[i, j, k] == i + j * 2 + k * 3 -def _test_grouped_ndrange(): +@test_utils.test() +def test_grouped_ndrange(): val = ti.field(ti.i32) n = 4 @@ -86,16 +78,6 @@ def test(): j * 2 if x0 <= i < y0 and x1 <= j < y1 else 0) -@test_utils.test() -def test_grouped_ndrange(): - _test_grouped_ndrange() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_grouped_ndrange_matrix_scalarize(): - _test_grouped_ndrange() - - @test_utils.test() def test_static_grouped_ndrange(): val = ti.field(ti.i32) @@ -123,7 +105,8 @@ def test(): j * 2 if x0 <= i < y0 and x1 <= j < y1 else 0) -def _test_grouped_ndrange_starred(): +@test_utils.test() +def test_grouped_ndrange_starred(): val = ti.field(ti.i32) n = 4 @@ -147,16 +130,6 @@ def test(): k] == (i + j * 2 + k * 3 if j < n and k < n else 0) -@test_utils.test() -def test_grouped_ndrange_starred(): - _test_grouped_ndrange_starred() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_grouped_ndrange_starred_matrix_scalarize(): - _test_grouped_ndrange_starred() - - @test_utils.test() def test_grouped_ndrange_0d(): val = ti.field(ti.i32, shape=()) @@ -185,7 +158,8 @@ def test(): assert val[None] == 42 -def _test_static_grouped_func(): +@test_utils.test() +def test_static_grouped_func(): K = 3 dim = 2 @@ -206,13 +180,3 @@ def p2g(): for j in range(K): for k in range(K): assert v[i, j][k] == i + j * 3 + k * 10 - - -@test_utils.test() -def test_static_grouped_func(): - _test_static_grouped_func() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_static_grouped_func_matrix_scalarize(): - _test_static_grouped_func() diff --git a/tests/python/test_indices.py b/tests/python/test_indices.py index bffdb0ddcf0d4..ee090b8b5fa87 100644 --- a/tests/python/test_indices.py +++ b/tests/python/test_indices.py @@ -54,9 +54,7 @@ def prefix_sum(): assert (val[i] == i + 1) -@test_utils.test(arch=[ti.cpu, ti.cuda], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test() def test_indices_with_matrix(): grid_m = ti.field(dtype=ti.i32, shape=(10, 10)) diff --git a/tests/python/test_linalg.py b/tests/python/test_linalg.py index 463ee2fb8f522..cdad4e3325e8e 100644 --- a/tests/python/test_linalg.py +++ b/tests/python/test_linalg.py @@ -28,7 +28,8 @@ def init(): assert b[None][j] == j -def _test_basic_utils(): +@test_utils.test() +def test_basic_utils(): a = ti.Vector.field(3, dtype=ti.f32) b = ti.Vector.field(2, dtype=ti.f32) abT = ti.Matrix.field(3, 2, dtype=ti.f32) @@ -69,16 +70,7 @@ def init(): @test_utils.test() -def test_basic_utils(): - _test_basic_utils() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_basic_utils_real_matrix_scalarize(): - _test_basic_utils() - - -def _test_cross(): +def test_cross(): a = ti.Vector.field(3, dtype=ti.f32) b = ti.Vector.field(3, dtype=ti.f32) c = ti.Vector.field(3, dtype=ti.f32) @@ -107,16 +99,7 @@ def init(): @test_utils.test() -def test_cross(): - _test_cross() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_cross_real_matrix_scalarize(): - _test_cross() - - -def _test_dot(): +def test_dot(): a = ti.Vector.field(3, dtype=ti.f32) b = ti.Vector.field(3, dtype=ti.f32) c = ti.field(dtype=ti.f32) @@ -142,16 +125,6 @@ def init(): assert c2[None] == 14.0 -@test_utils.test() -def test_dot(): - _test_dot() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_dot_real_matrix_scalarize(): - _test_dot() - - @test_utils.test() def test_transpose(): dim = 3 @@ -223,24 +196,6 @@ def test_polar_decomp_f64(dim): _test_polar_decomp(dim, ti.f64) -@pytest.mark.parametrize("dim", [2, 3]) -@test_utils.test(default_fp=ti.f32, - exclude=ti.opengl, - real_matrix=True, - real_matrix_scalarize=True) -def test_polar_decomp_f32_real_matrix_scalarize(dim): - _test_polar_decomp(dim, ti.f32) - - -@pytest.mark.parametrize("dim", [2, 3]) -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - real_matrix=True, - real_matrix_scalarize=True) -def test_polar_decomp_f64_real_matrix_scalarize(dim): - _test_polar_decomp(dim, ti.f64) - - @test_utils.test() def test_matrix(): x = ti.Matrix.field(2, 2, dtype=ti.i32) @@ -265,7 +220,9 @@ def inc(): assert x[i][1, 1] == 1 + i -def _test_mat_inverse_size(n): +@pytest.mark.parametrize("n", range(1, 5)) +@test_utils.test() +def test_mat_inverse_size(n): m = ti.Matrix.field(n, n, dtype=ti.f32, shape=()) M = np.empty(shape=(n, n), dtype=np.float32) for i in range(n): @@ -285,19 +242,8 @@ def invert(): np.testing.assert_almost_equal(m_np, np.linalg.inv(M)) -@pytest.mark.parametrize("n", range(1, 5)) @test_utils.test() -def test_mat_inverse_size(n): - _test_mat_inverse_size(n) - - -@pytest.mark.parametrize("n", range(1, 5)) -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_mat_inverse_size_real_matrix_scalarize(n): - _test_mat_inverse_size(n) - - -def _test_matrix_factories(): +def test_matrix_factories(): a = ti.Vector.field(3, dtype=ti.i32, shape=3) b = ti.Matrix.field(2, 2, dtype=ti.f32, shape=2) c = ti.Matrix.field(2, 3, dtype=ti.f32, shape=2) @@ -326,16 +272,7 @@ def fill(): @test_utils.test() -def test_matrix_factories(): - _test_matrix_factories() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_matrix_factories_real_matrix_scalarize(): - _test_matrix_factories() - - -def _test_init_matrix_from_vectors(): +def test_init_matrix_from_vectors(): m1 = ti.Matrix.field(3, 3, dtype=ti.f32, shape=(3)) m2 = ti.Matrix.field(3, 3, dtype=ti.f32, shape=(3)) m3 = ti.Matrix.field(3, 3, dtype=ti.f32, shape=(3)) @@ -365,16 +302,7 @@ def fill(): @test_utils.test() -def test_init_matrix_from_vectors(): - _test_init_matrix_from_vectors() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_init_matrix_from_vectors_matrix_scalarize(): - _test_init_matrix_from_vectors() - - -def _test_any_all(): +def test_any_all(): a = ti.Matrix.field(2, 2, dtype=ti.i32, shape=()) b = ti.field(dtype=ti.i32, shape=()) c = ti.field(dtype=ti.i32, shape=()) @@ -403,16 +331,6 @@ def func(): assert c[None] == 0 -@test_utils.test() -def test_any_all(): - _test_any_all() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_any_all_real_matrix_scalarize(): - _test_any_all() - - @test_utils.test() def test_min_max(): a = ti.Matrix.field(2, 2, dtype=ti.i32, shape=()) diff --git a/tests/python/test_math_module.py b/tests/python/test_math_module.py index c155ec841d9f0..b6f586cea10ae 100644 --- a/tests/python/test_math_module.py +++ b/tests/python/test_math_module.py @@ -93,8 +93,9 @@ def test(): test() +@test_utils.test(debug=True) @ti.kernel -def _test_translate(): +def test_translate(): error = 0 translate_vec = ti.math.vec3(1., 2., 3.) translate_mat = ti.math.translate(translate_vec[0], translate_vec[1], @@ -106,17 +107,8 @@ def _test_translate(): @test_utils.test(debug=True) -def test_translate(): - _test_translate() - - -@test_utils.test(debug=True, real_matrix=True, real_matrix_scalarize=True) -def test_translate_real_matrix_scalarize(): - _test_translate() - - @ti.kernel -def _test_scale(): +def test_scale(): error = 0 scale_vec = ti.math.vec3(1., 2., 3.) scale_mat = ti.math.scale(scale_vec[0], scale_vec[1], scale_vec[2]) @@ -127,17 +119,8 @@ def _test_scale(): @test_utils.test(debug=True) -def test_scale(): - _test_scale() - - -@test_utils.test(debug=True, real_matrix=True, real_matrix_scalarize=True) -def test_scale_real_matrix_scalarize(): - _test_scale() - - @ti.kernel -def _test_rotation2d(): +def test_rotation2d(): error = 0 rotationTest = ti.math.rotation2d(ti.math.radians(30)) rotationRef = ti.math.mat2([[0.866025, -0.500000], [0.500000, 0.866025]]) @@ -146,17 +129,8 @@ def _test_rotation2d(): @test_utils.test(debug=True) -def test_rotation2d(): - _test_rotation2d() - - -@test_utils.test(debug=True, real_matrix=True, real_matrix_scalarize=True) -def test_rotation2d_real_matrix_scalarize(): - _test_rotation2d() - - @ti.kernel -def _test_rotation3d(): +def test_rotation3d(): error = 0 first = 1.046 @@ -192,13 +166,3 @@ def _test_rotation3d(): error += check_epsilon_equal(rotationEuler, rotationTest, 0.00001) assert error == 0 - - -@test_utils.test(debug=True) -def test_rotation3d(): - _test_rotation3d() - - -@test_utils.test(debug=True, real_matrix=True, real_matrix_scalarize=True) -def test_rotation3d_real_matrix_scalarize(): - _test_rotation3d() diff --git a/tests/python/test_matrix.py b/tests/python/test_matrix.py index 7c95bb904abea..333ee50fd2295 100644 --- a/tests/python/test_matrix.py +++ b/tests/python/test_matrix.py @@ -122,7 +122,8 @@ def func(t: ti.i32): func(5) -def _test_taichi_scope_vector_operations_with_global_vectors(): +@test_utils.test(arch=get_host_arch_list()) +def test_taichi_scope_vector_operations_with_global_vectors(): for ops in vector_operation_types: a, b, c = test_vector_arrays[:3] m1, m2 = ti.Vector(a), ti.Vector(b) @@ -143,18 +144,7 @@ def run(): @test_utils.test(arch=get_host_arch_list()) -def test_taichi_scope_vector_operations_with_global_vectors(): - _test_taichi_scope_vector_operations_with_global_vectors() - - -@test_utils.test(arch=get_host_arch_list(), - real_matrix=True, - real_matrix_scalarize=True) -def test_taichi_scope_vector_operations_with_global_vectors_matrix_scalarize(): - _test_taichi_scope_vector_operations_with_global_vectors() - - -def _test_taichi_scope_matrix_operations_with_global_matrices(): +def test_taichi_scope_matrix_operations_with_global_matrices(): for ops in matrix_operation_types: a, b, c = test_matrix_arrays[:3] m1, m2 = ti.Matrix(a), ti.Matrix(b) @@ -174,19 +164,6 @@ def run(): assert np.allclose(r2[None].to_numpy(), ops(a, c)) -@test_utils.test(arch=get_host_arch_list()) -def test_taichi_scope_matrix_operations_with_global_matrices(): - _test_taichi_scope_matrix_operations_with_global_matrices() - - -@test_utils.test(arch=get_host_arch_list(), - real_matrix=True, - real_matrix_scalarize=True) -def test_taichi_scope_matrix_operations_with_global_matrices_matrix_scalarize( -): - _test_taichi_scope_matrix_operations_with_global_matrices() - - def _test_local_matrix_non_constant_index(): @ti.kernel def func1(): @@ -220,22 +197,12 @@ def test_local_matrix_non_constant_index(): @test_utils.test(require=ti.extension.dynamic_index, - real_matrix=True, real_matrix_scalarize=False, debug=True) def test_local_matrix_non_constant_index_real_matrix(): _test_local_matrix_non_constant_index() -@test_utils.test(require=ti.extension.dynamic_index, - dynamic_index=True, - real_matrix=True, - real_matrix_scalarize=True, - debug=True) -def test_local_matrix_non_constant_index_real_matrix_scalarize(): - _test_local_matrix_non_constant_index() - - @test_utils.test(exclude=[ti.cc]) def test_matrix_ndarray_non_constant_index(): @ti.kernel @@ -634,7 +601,8 @@ def test_python_scope_inplace_operator(): assert np.allclose(m1.to_numpy(), ops(a, b)) -def _test_indexing(): +@test_utils.test() +def test_indexing(): @ti.kernel def foo(): m = ti.Matrix([[0., 0., 0., 0.] for _ in range(4)]) @@ -654,7 +622,8 @@ def bar(): bar() -def _test_indexing_in_fields(): +@test_utils.test() +def test_indexing_in_fields(): f = ti.Matrix.field(3, 3, ti.f32, shape=()) @ti.kernel @@ -678,7 +647,8 @@ def bar(): bar() -def _test_indexing_in_struct(): +@test_utils.test() +def test_indexing_in_struct(): @ti.kernel def foo(): s = ti.Struct(a=ti.Vector([0, 0, 0]), b=2) @@ -698,7 +668,8 @@ def bar(): bar() -def _test_indexing_in_struct_field(): +@test_utils.test() +def test_indexing_in_struct_field(): s = ti.Struct.field( { @@ -724,46 +695,6 @@ def bar(): bar() -@test_utils.test() -def test_indexing_in_struct_field(): - _test_indexing_in_struct_field() - - -@test_utils.test() -def test_indexing_in_struct(): - _test_indexing_in_struct() - - -@test_utils.test() -def test_indexing_in_fields(): - _test_indexing_in_fields() - - -@test_utils.test() -def test_indexing(): - _test_indexing() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_indexing_in_struct_field_matrix_scalarize(): - _test_indexing_in_struct_field() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_indexing_in_struct_matrix_scalarize(): - _test_indexing_in_struct() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_indexing_in_fields_matrix_scalarize(): - _test_indexing_in_fields() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_indexing_matrix_scalarize(): - _test_indexing() - - @test_utils.test(arch=get_host_arch_list(), debug=True) def test_matrix_vector_multiplication(): mat = ti.math.mat3(1) @@ -782,9 +713,7 @@ def foo(): foo() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=False) +@test_utils.test(arch=[ti.cuda, ti.cpu], real_matrix_scalarize=False) def test_local_matrix_read(): s = ti.field(ti.i32, shape=()) @@ -800,9 +729,7 @@ def get_index(i: ti.i32, j: ti.i32): assert s[None] == i * 3 + j -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=False) +@test_utils.test(arch=[ti.cuda, ti.cpu], real_matrix_scalarize=False) def test_local_matrix_read_without_assign(): @ti.kernel def local_vector_read(i: ti.i32) -> ti.i32: @@ -812,9 +739,7 @@ def local_vector_read(i: ti.i32) -> ti.i32: assert local_vector_read(i) == i -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=False) +@test_utils.test(arch=[ti.cuda, ti.cpu], real_matrix_scalarize=False) def test_local_matrix_indexing_in_loop(): s = ti.field(ti.i32, shape=(3, 3)) @@ -831,9 +756,7 @@ def test(): assert s[i, j] == i * 3 + j + 1 -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=False) +@test_utils.test(arch=[ti.cuda, ti.cpu], real_matrix_scalarize=False) def test_local_matrix_indexing_ops(): @ti.kernel def element_write() -> ti.i32: @@ -868,7 +791,7 @@ def assign_from_index(): assert f[i, j] == xs[j][i] -@test_utils.test(arch=[ti.cuda, ti.cpu], real_matrix=True) +@test_utils.test() def test_local_matrix_index_check(): @ti.kernel def foo(): @@ -890,7 +813,6 @@ def bar(): @test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, real_matrix_scalarize=False, debug=True) def test_elementwise_ops(): @@ -953,9 +875,7 @@ def test(): test() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test(debug=True) def test_local_matrix_scalarize(): @ti.kernel def func(): @@ -973,10 +893,8 @@ def func(): # Unary x[1, 1] = ti.sqrt(x[1, 0]) - # TODO: test for dynamic indexing - assert (x[0, 0] == 100.) - assert (x[0, 1] == 200.) + assert (x[0, 1] == 100.) assert (x[1, 0] == 200.) assert (x[1, 1] < 14.14214) assert (x[1, 1] > 14.14213) @@ -1010,9 +928,7 @@ def kern_ndarray(a: ti.types.ndarray()): verify(ndarray) -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test() def test_store_scalarize(): @ti.func def func(a: ti.template()): @@ -1031,9 +947,7 @@ def verify(x): _test_field_and_ndarray(field, ndarray, func, verify) -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test() def test_load_store_scalarize(): @ti.func def func(a: ti.template()): @@ -1052,9 +966,7 @@ def verify(x): _test_field_and_ndarray(field, ndarray, func, verify) -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test() def test_unary_op_scalarize(): @ti.func def func(a: ti.template()): @@ -1078,9 +990,7 @@ def verify(x): _test_field_and_ndarray(field, ndarray, func, verify) -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test() def test_binary_op_scalarize(): @ti.func def func(a: ti.template()): @@ -1100,9 +1010,7 @@ def verify(x): _test_field_and_ndarray(field, ndarray, func, verify) -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True) +@test_utils.test() def test_trace_op(): @ti.kernel def test_fun() -> ti.f32: @@ -1129,10 +1037,7 @@ def failed_func(): failed_func() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True, - debug=True) +@test_utils.test(debug=True) def test_ternary_op_scalarize(): @ti.kernel def test(): @@ -1149,10 +1054,7 @@ def test(): test() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True, - debug=True) +@test_utils.test(debug=True) def test_fill_op(): @ti.kernel def test_fun(): @@ -1165,10 +1067,7 @@ def test_fun(): test_fun() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True, - debug=True) +@test_utils.test(debug=True) def test_atomic_op_scalarize(): @ti.func def func(x: ti.template()): @@ -1195,7 +1094,7 @@ def verify(x): _test_field_and_ndarray(field, ndarray, func, verify) -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) +@test_utils.test() def test_unsupported_logical_operations(): @ti.kernel def test(): @@ -1225,10 +1124,7 @@ def foo(): foo() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True, - debug=True) +@test_utils.test(debug=True) def test_cross_scope_matrix_binary_ops(): n = 128 x = ti.Vector.field(3, dtype=int, shape=(n, n)) @@ -1249,10 +1145,7 @@ def test(): assert (x[6, 8] == [1, 10, 100]).all() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True, - debug=True) +@test_utils.test(debug=True) def test_cross_scope_matrix_ternary_ops(): n = 128 x = ti.Vector.field(3, dtype=int, shape=(n, n)) @@ -1269,10 +1162,7 @@ def test(): assert (x[1, 1] == [100, 10, 1]).all() -@test_utils.test(arch=[ti.cuda, ti.cpu], - real_matrix=True, - real_matrix_scalarize=True, - debug=True) +@test_utils.test(debug=True) def test_cross_scope_matrix_atomic_ops(): n = 128 x = ti.Vector.field(3, dtype=int, shape=(n, n)) diff --git a/tests/python/test_matrix_return.py b/tests/python/test_matrix_return.py index 2dee78a94837c..cc90bece2630b 100644 --- a/tests/python/test_matrix_return.py +++ b/tests/python/test_matrix_return.py @@ -15,16 +15,11 @@ def test_vector_return(): _test_vector_return() -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_vector_return_real_matrix(): _test_vector_return() -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_vector_return_real_matrix_scalarize(): - _test_vector_return() - - def _test_matrix_return(): @ti.kernel def func() -> ti.types.matrix(2, 3, ti.i16): @@ -38,18 +33,11 @@ def test_matrix_return(): _test_matrix_return() -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_matrix_return_real_matrix(): _test_matrix_return() -@test_utils.test(arch=[ti.cpu, ti.cuda, ti.metal], - real_matrix=True, - real_matrix_scalarize=True) -def test_matrix_return_real_matrix_scalarize(): - _test_matrix_return() - - def _test_matrix_return_limit(): @ti.kernel def func() -> ti.types.matrix(3, 10, ti.i32): @@ -68,11 +56,6 @@ def test_matrix_return_limit(): _test_matrix_return_limit() -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_matrix_return_limit_real_matrix(): _test_matrix_return_limit() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_matrix_return_limit_real_matrix_scalarize(): - _test_matrix_return_limit() diff --git a/tests/python/test_matrix_slice.py b/tests/python/test_matrix_slice.py index 200d3ead63394..06dd0a4b81049 100644 --- a/tests/python/test_matrix_slice.py +++ b/tests/python/test_matrix_slice.py @@ -4,7 +4,8 @@ from tests import test_utils -def _test_matrix_slice_read(): +@test_utils.test() +def test_matrix_slice_read(): b = 6 @ti.kernel @@ -28,16 +29,7 @@ def foo2() -> ti.types.matrix(2, 3, dtype=ti.i32): @test_utils.test() -def test_matrix_slice_read(): - _test_matrix_slice_read() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_matrix_slice_read_real_matrix_scalarize(): - _test_matrix_slice_read() - - -def _test_matrix_slice_invalid(): +def test_matrix_slice_invalid(): @ti.kernel def foo1(i: ti.i32): a = ti.Vector([0, 1, 2, 3, 4, 5, 6]) @@ -57,17 +49,8 @@ def foo2(): foo2() -@test_utils.test() -def test_matrix_slice_invalid(): - _test_matrix_slice_invalid() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_matrix_slice_invalid_real_matrix_scalarize(): - _test_matrix_slice_invalid() - - -def _test_matrix_slice_with_variable(): +@test_utils.test(dynamic_index=True) +def test_matrix_slice_with_variable(): @ti.kernel def test_one_row_slice() -> ti.types.matrix(2, 1, dtype=ti.i32): m = ti.Matrix([[1, 2, 3], [4, 5, 6]]) @@ -86,19 +69,8 @@ def test_one_col_slice() -> ti.types.matrix(1, 3, dtype=ti.i32): assert (c1 == ti.Matrix([[4, 5, 6]])).all() -@test_utils.test(dynamic_index=True) -def test_matrix_slice_with_variable(): - _test_matrix_slice_with_variable() - - -@test_utils.test(real_matrix=True, - real_matrix_scalarize=True, - dynamic_index=True) -def test_matrix_slice_with_variable_real_matrix_scalarize(): - _test_matrix_slice_with_variable() - - -def _test_matrix_slice_with_variable_invalid(): +@test_utils.test(dynamic_index=False) +def test_matrix_slice_with_variable_invalid(): @ti.kernel def test_one_col_slice() -> ti.types.matrix(1, 3, dtype=ti.i32): m = ti.Matrix([[1, 2, 3], [4, 5, 6]]) @@ -111,19 +83,8 @@ def test_one_col_slice() -> ti.types.matrix(1, 3, dtype=ti.i32): test_one_col_slice() -@test_utils.test(dynamic_index=False) -def test_matrix_slice_with_variable_invalid(): - _test_matrix_slice_with_variable_invalid() - - -@test_utils.test(dynamic_index=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_matrix_slice_with_variable_invalid_real_matrix_scalarize(): - _test_matrix_slice_with_variable_invalid() - - -def _test_matrix_slice_write(): +@test_utils.test() +def test_matrix_slice_write(): @ti.kernel def assign_row() -> ti.types.matrix(3, 4, ti.i32): mat = ti.Matrix([[0, 0, 0, 0] for _ in range(3)]) @@ -152,17 +113,8 @@ def augassign_rows() -> ti.types.matrix(3, 4, ti.i32): [1, 1, 1, 1]])).all() -@test_utils.test() -def test_matrix_slice_write(): - _test_matrix_slice_write() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_matrix_slice_write_real_matrix_scalarize(): - _test_matrix_slice_write() - - -def _test_matrix_slice_write_dynamic_index(): +@test_utils.test(dynamic_index=True) +def test_matrix_slice_write_dynamic_index(): @ti.kernel def foo(i: ti.i32) -> ti.types.matrix(3, 4, ti.i32): mat = ti.Matrix([[0, 0, 0, 0] for _ in range(3)]) @@ -172,15 +124,3 @@ def foo(i: ti.i32) -> ti.types.matrix(3, 4, ti.i32): for i in range(3): assert (foo(i) == ti.Matrix([[1, 2, 3, 4] if j == i else [0, 0, 0, 0] for j in range(3)])).all() - - -@test_utils.test(dynamic_index=True) -def test_matrix_slice_write_dynamic_index(): - _test_matrix_slice_write_dynamic_index() - - -@test_utils.test(real_matrix=True, - real_matrix_scalarize=True, - dynamic_index=True) -def test_matrix_slice_write_dynamic_index_real_matrix_scalarize(): - _test_matrix_slice_write_dynamic_index() diff --git a/tests/python/test_matrix_solve.py b/tests/python/test_matrix_solve.py index 13a30ec967760..b598884b46a06 100644 --- a/tests/python/test_matrix_solve.py +++ b/tests/python/test_matrix_solve.py @@ -91,41 +91,3 @@ def test_solve_3x3_f32(a00): fast_math=False) def test_solve_3x3_f64(a00): _test_solve_3x3(ti.f64, a00) - - -@pytest.mark.parametrize('a00', [float(i) for i in range(10)]) -@test_utils.test(default_fp=ti.f32, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_solve_2x2_f32_real_matrix_scalarize(a00): - _test_solve_2x2(ti.f32, a00) - - -@pytest.mark.parametrize('a00', [float(i) for i in range(10)]) -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_solve_2x2_f64_real_matrix_scalarize(a00): - _test_solve_2x2(ti.f64, a00) - - -@pytest.mark.parametrize('a00', [float(i) for i in range(10)]) -@test_utils.test(default_fp=ti.f32, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_solve_3x3_f32_real_matrix_scalarize(a00): - _test_solve_3x3(ti.f32, a00) - - -@pytest.mark.parametrize('a00', [float(i) for i in range(10)]) -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_solve_3x3_f64_real_matrix_scalarize(a00): - _test_solve_3x3(ti.f64, a00) diff --git a/tests/python/test_mpm88.py b/tests/python/test_mpm88.py index ecaf662500326..6a55800f5737f 100644 --- a/tests/python/test_mpm88.py +++ b/tests/python/test_mpm88.py @@ -6,7 +6,10 @@ from tests import test_utils -def run_mpm88_test(): +@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') +@pytest.mark.run_in_serial +@test_utils.test() +def test_mpm88(): dim = 2 N = 64 n_particles = N * N @@ -102,20 +105,6 @@ def substep(): rel=1e-2) -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -@pytest.mark.run_in_serial -@test_utils.test() -def test_mpm88(): - run_mpm88_test() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -@pytest.mark.run_in_serial -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_mpm88_real_matrix_scalarize(): - run_mpm88_test() - - def _is_appveyor(): # AppVeyor adds `APPVEYOR=True` ('true' on Ubuntu) # https://www.appveyor.com/docs/environment-variables/ diff --git a/tests/python/test_ndarray.py b/tests/python/test_ndarray.py index e9e435f81fdf2..df639130982cd 100644 --- a/tests/python/test_ndarray.py +++ b/tests/python/test_ndarray.py @@ -180,7 +180,8 @@ def test_ndarray_compound_element(): assert c.element_type.shape() == (3, 4) -def _test_ndarray_copy_from_ndarray(): +@test_utils.test(arch=supported_archs_taichi_ndarray) +def test_ndarray_copy_from_ndarray(): n = 16 a = ti.ndarray(ti.i32, shape=n) b = ti.ndarray(ti.i32, shape=n) @@ -220,18 +221,7 @@ def _test_ndarray_copy_from_ndarray(): @test_utils.test(arch=supported_archs_taichi_ndarray) -def test_ndarray_copy_from_ndarray(): - _test_ndarray_copy_from_ndarray() - - -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_ndarray_copy_from_ndarray_matrix_scalarize(): - _test_ndarray_copy_from_ndarray() - - -def _test_ndarray_deepcopy(): +def test_ndarray_deepcopy(): n = 16 x = ti.ndarray(ti.i32, shape=n) x[0] = 1 @@ -326,18 +316,6 @@ def test_ndarray_rw_cache(): c_a[None] = c_b[10] -@test_utils.test(arch=supported_archs_taichi_ndarray) -def test_ndarray_deepcopy(): - _test_ndarray_deepcopy() - - -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_ndarray_deepcopy_matrix_scalarize(): - _test_ndarray_deepcopy() - - def _test_ndarray_numpy_io(): n = 7 m = 4 @@ -421,18 +399,11 @@ def test_matrix_ndarray_taichi_scope(): _test_matrix_ndarray_taichi_scope() -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_matrix_ndarray_taichi_scope_real_matrix(): _test_matrix_ndarray_taichi_scope() -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_matrix_ndarray_taichi_scope_real_matrix_scalarize(): - _test_matrix_ndarray_taichi_scope() - - def _test_matrix_ndarray_taichi_scope_struct_for(): @ti.kernel def func(a: ti.types.ndarray()): @@ -454,18 +425,11 @@ def test_matrix_ndarray_taichi_scope_struct_for(): _test_matrix_ndarray_taichi_scope_struct_for() -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_matrix_ndarray_taichi_scope_struct_for_real_matrix(): _test_matrix_ndarray_taichi_scope_struct_for() -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_matrix_ndarray_taichi_scope_struct_for_matrix_scalarize(): - _test_matrix_ndarray_taichi_scope_struct_for() - - @test_utils.test(arch=supported_archs_taichi_ndarray) def test_vector_ndarray_python_scope(): a = ti.Vector.ndarray(10, ti.i32, 5) @@ -500,14 +464,7 @@ def test_vector_ndarray_taichi_scope(): _test_vector_ndarray_taichi_scope() -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_vector_ndarray_taichi_scope_matrix_scalarize(): - _test_vector_ndarray_taichi_scope() - - -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_vector_ndarray_taichi_scope_real_matrix(): _test_vector_ndarray_taichi_scope() @@ -664,18 +621,11 @@ def test_ndarray_grouped(): _test_ndarray_grouped() -@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix=True) +@test_utils.test(arch=[ti.cpu, ti.cuda], real_matrix_scalarize=False) def test_ndarray_grouped_real_matrix(): _test_ndarray_grouped() -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_ndarray_grouped_real_matrix_scalarize(): - _test_ndarray_grouped() - - @test_utils.test(arch=supported_archs_taichi_ndarray) def test_ndarray_as_template(): @ti.kernel @@ -719,10 +669,8 @@ def fill_gaussian_kernel(ker: ti.types.ndarray(ti.f32, ndim=1), N: ti.i32): assert test_utils.allclose(res, np_arr) -@test_utils.test(arch=supported_archs_taichi_ndarray, - real_matrix=True, - real_matrix_scalarize=True) -def test_ndarray_numpy_matrix_scalarize(): +@test_utils.test(arch=supported_archs_taichi_ndarray) +def test_ndarray_numpy_matrix(): boundary_box_np = np.array([[0, 0, 0], [1, 1, 1]], dtype=np.float32) boundary_box = ti.Vector.ndarray(3, ti.f32, shape=2) boundary_box.from_numpy(boundary_box_np) diff --git a/tests/python/test_ndrange.py b/tests/python/test_ndrange.py index d39eeba5cb968..94c107d81c4d4 100644 --- a/tests/python/test_ndrange.py +++ b/tests/python/test_ndrange.py @@ -108,7 +108,8 @@ def func(): assert x[i, j, k] == 0 -def _test_static_grouped_static(): +@test_utils.test() +def test_static_grouped_static(): x = ti.Matrix.field(2, 3, dtype=ti.f32, shape=(16, 4)) @ti.kernel @@ -125,16 +126,6 @@ def func(): assert x[i, j][k, l] == k + l * 10 + i + j * 4 -@test_utils.test() -def test_static_grouped_static(): - _test_static_grouped_static() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_static_grouped_static_matrix_scalarize(): - _test_static_grouped_static() - - @test_utils.test() def test_field_init_eye(): # https://github.com/taichi-dev/taichi/issues/1824 @@ -230,7 +221,8 @@ def func(): assert A[i, j] == r -def _test_grouped_ndrange_star(): +@test_utils.test() +def test_grouped_ndrange_star(): @ti.kernel def foo() -> ti.i32: ret = 0 @@ -241,16 +233,6 @@ def foo() -> ti.i32: assert foo() == 36 -@test_utils.test() -def test_grouped_ndrange_star(): - _test_grouped_ndrange_star() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_grouped_ndrange_star_matrix_scalarize(): - _test_grouped_ndrange_star() - - @test_utils.test() def test_ndrange_three_arguments(): @ti.kernel diff --git a/tests/python/test_print.py b/tests/python/test_print.py index 1eecce5e9c2af..4a57cef29c6bf 100644 --- a/tests/python/test_print.py +++ b/tests/python/test_print.py @@ -104,7 +104,8 @@ def func(k: ti.f32): ti.sync() -def _test_print_list(): +@test_utils.test(exclude=[ti.cc, ti.dx11, vk_on_mac], debug=True) +def test_print_list(): x = ti.Matrix.field(2, 3, dtype=ti.f32, shape=(2, 3)) y = ti.Vector.field(3, dtype=ti.f32, shape=()) @@ -124,19 +125,6 @@ def func(k: ti.f32): ti.sync() -@test_utils.test(exclude=[ti.cc, ti.dx11, vk_on_mac], debug=True) -def test_print_list(): - _test_print_list() - - -@test_utils.test(exclude=[ti.cc, ti.dx11, vk_on_mac], - debug=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_print_list_matrix_scalarize(): - _test_print_list() - - @test_utils.test(arch=[ti.cpu, ti.vulkan], exclude=[vk_on_mac], debug=True) def test_python_scope_print_field(): x = ti.Matrix.field(2, 3, dtype=ti.f32, shape=()) diff --git a/tests/python/test_quant_atomics.py b/tests/python/test_quant_atomics.py index eee857800c849..fb98939f0b9fc 100644 --- a/tests/python/test_quant_atomics.py +++ b/tests/python/test_quant_atomics.py @@ -43,7 +43,9 @@ def foo(): assert z[None] == 3 -def _test_quant_int_atomics_b64(): +@test_utils.test(require=[ti.extension.quant_basic, ti.extension.data64], + debug=True) +def test_quant_int_atomics_b64(): qi13 = ti.types.quant.int(13, True) x = ti.field(dtype=qi13) @@ -66,21 +68,8 @@ def foo(): assert x[2] == 315 -@test_utils.test(require=[ti.extension.quant_basic, ti.extension.data64], - debug=True) -def test_quant_int_atomics_b64(): - _test_quant_int_atomics_b64() - - -@test_utils.test(require=[ti.extension.quant_basic, ti.extension.data64], - debug=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_quant_int_atomics_b64_real_matrix_scalarize(): - _test_quant_int_atomics_b64() - - -def _test_quant_fixed_atomics(): +@test_utils.test(require=ti.extension.quant_basic, debug=True) +def test_quant_fixed_atomics(): qfxt13 = ti.types.quant.fixed(bits=13, signed=True, scale=0.1) qfxt19 = ti.types.quant.fixed(bits=19, signed=False, scale=0.1) @@ -102,16 +91,3 @@ def foo(): foo() assert x[None] == approx(-3.3) assert y[None] == approx(1124.4) - - -@test_utils.test(require=ti.extension.quant_basic, debug=True) -def test_quant_fixed_atomics(): - _test_quant_fixed_atomics() - - -@test_utils.test(require=ti.extension.quant_basic, - debug=True, - real_matrix=True, - real_matrix_scalarize=True) -def test_quant_fixed_atomics_real_matrix_scalarize(): - _test_quant_fixed_atomics() diff --git a/tests/python/test_scalar_op.py b/tests/python/test_scalar_op.py index 4f0b4ec36bcf5..49fd7b16f8f54 100644 --- a/tests/python/test_scalar_op.py +++ b/tests/python/test_scalar_op.py @@ -174,7 +174,8 @@ def max_i64(a: ti.i64, b: ti.i64) -> ti.i64: assert max_i64(a, b) == max(a, b) -def _test_min_max_vector_starred(): +@test_utils.test() +def test_min_max_vector_starred(): @ti.kernel def min_starred() -> ti.i32: a = ti.Vector([1, 2, 3]) @@ -189,13 +190,3 @@ def max_starred() -> ti.i32: assert min_starred() == 1 assert max_starred() == 6 - - -@test_utils.test() -def test_min_max_vector_starred(): - _test_min_max_vector_starred() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_min_max_vector_starred_matrix_scalarize(): - _test_min_max_vector_starred() diff --git a/tests/python/test_scan.py b/tests/python/test_scan.py index bdebaa62fb993..55ff669aee5ee 100644 --- a/tests/python/test_scan.py +++ b/tests/python/test_scan.py @@ -2,7 +2,8 @@ from tests import test_utils -def _test_scan(): +@test_utils.test(arch=[ti.cuda, ti.vulkan], exclude=[(ti.vulkan, "Darwin")]) +def test_scan(): def test_scan_for_dtype(dtype, N): arr = ti.field(dtype, N) arr_aux = ti.field(dtype, N) @@ -29,16 +30,3 @@ def fill(): test_scan_for_dtype(ti.i32, 512) test_scan_for_dtype(ti.i32, 1024) test_scan_for_dtype(ti.i32, 4096) - - -@test_utils.test(arch=[ti.cuda, ti.vulkan], exclude=[(ti.vulkan, "Darwin")]) -def test_scan(): - _test_scan() - - -@test_utils.test(arch=[ti.cuda, ti.vulkan], - exclude=[(ti.vulkan, "Darwin")], - real_matrix=True, - real_matrix_scalarize=True) -def test_scan_matrix_scalarize(): - _test_scan() diff --git a/tests/python/test_shared_array.py b/tests/python/test_shared_array.py index c92bdcb9ce38c..c9a9d706f36d6 100644 --- a/tests/python/test_shared_array.py +++ b/tests/python/test_shared_array.py @@ -4,7 +4,8 @@ from tests import test_utils -def _test_shared_array_nested_loop(): +@test_utils.test(arch=[ti.cuda, ti.vulkan]) +def test_shared_array_nested_loop(): block_dim = 128 nBlocks = 64 N = nBlocks * block_dim @@ -44,15 +45,3 @@ def calc_shared_array(v: ti.types.ndarray(ndim=1), calc(v_arr, d_arr, reference) calc_shared_array(v_arr, d_arr, a_arr) assert np.allclose(reference, a_arr) - - -@test_utils.test(arch=[ti.cuda, ti.vulkan]) -def test_shared_array_nested_loop(): - _test_shared_array_nested_loop() - - -@test_utils.test(arch=[ti.cuda, ti.vulkan], - real_matrix=True, - real_matrix_scalarize=True) -def test_shared_array_nested_loop_matrix_scalarize(): - _test_shared_array_nested_loop() diff --git a/tests/python/test_svd.py b/tests/python/test_svd.py index 217b02e128950..9095078107d3e 100644 --- a/tests/python/test_svd.py +++ b/tests/python/test_svd.py @@ -76,26 +76,8 @@ def test_svd_f64(dim): _test_svd(ti.f64, dim) -@pytest.mark.parametrize("dim", [2, 3]) -@test_utils.test(default_fp=ti.f32, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_svd_f32_real_matrix_scalarize(dim): - _test_svd(ti.f32, dim) - - -@pytest.mark.parametrize("dim", [2, 3]) -@test_utils.test(require=ti.extension.data64, - default_fp=ti.f64, - fast_math=False, - real_matrix=True, - real_matrix_scalarize=True) -def test_svd_f64_real_matrix_scalarize(dim): - _test_svd(ti.f64, dim) - - -def _test_transpose_no_loop(): +@test_utils.test() +def test_transpose_no_loop(): A = ti.Matrix.field(3, 3, dtype=ti.f32, shape=()) U = ti.Matrix.field(3, 3, dtype=ti.f32, shape=()) sigma = ti.Matrix.field(3, 3, dtype=ti.f32, shape=()) @@ -107,13 +89,3 @@ def run(): run() # As long as it passes compilation we are good - - -@test_utils.test() -def test_transpose_no_loop(): - _test_transpose_no_loop() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_transpose_no_loop_real_matrix_scalarize(): - _test_transpose_no_loop() diff --git a/tests/python/test_texture.py b/tests/python/test_texture.py index 54b2c697e645c..aba98a9eb4385 100644 --- a/tests/python/test_texture.py +++ b/tests/python/test_texture.py @@ -137,7 +137,8 @@ def init_taichi_logo_ndarray(f: ti.types.ndarray(ndim=2)): tex.from_ndarray(f) -def _test_texture_3d(): +@test_utils.test(arch=supported_archs_texture) +def test_texture_3d(): res = (32, 32, 32) tex = ti.Texture(ti.Format.r32f, res) @@ -145,18 +146,7 @@ def _test_texture_3d(): @test_utils.test(arch=supported_archs_texture) -def test_texture_3d(): - _test_texture_3d() - - -@test_utils.test(arch=supported_archs_texture, - real_matrix=True, - real_matrix_scalarize=True) -def test_texture_3d_real_matrix_scalarize(): - _test_texture_3d() - - -def _test_from_to_image(): +def test_from_to_image(): url = 'https://github.com/taichi-dev/taichi/blob/master/misc/logo.png?raw=true' response = requests.get(url) img = Image.open(BytesIO(response.content)) @@ -169,18 +159,7 @@ def _test_from_to_image(): @test_utils.test(arch=supported_archs_texture) -def test_from_to_image(): - _test_from_to_image() - - -@test_utils.test(arch=supported_archs_texture, - real_matrix=True, - real_matrix_scalarize=True) -def test_from_to_image_real_matrix_scalarize(): - _test_from_to_image() - - -def _test_rw_texture_2d_struct_for(): +def test_rw_texture_2d_struct_for(): res = (128, 128) tex = ti.Texture(ti.Format.r32f, res) arr = ti.ndarray(ti.f32, res) @@ -202,18 +181,6 @@ def read(tex: ti.types.texture(num_dimensions=2), arr: ti.types.ndarray()): assert arr.to_numpy().sum() == 128 * 128 -@test_utils.test(arch=supported_archs_texture) -def test_rw_texture_2d_struct_for(): - _test_rw_texture_2d_struct_for() - - -@test_utils.test(arch=supported_archs_texture, - real_matrix=True, - real_matrix_scalarize=True) -def test_rw_texture_2d_struct_for_real_matrix_scalarize(): - _test_rw_texture_2d_struct_for() - - @test_utils.test(arch=supported_archs_texture) def test_rw_texture_2d_struct_for_dim_check(): tex = ti.Texture(ti.Format.r32f, (32, 32, 32)) diff --git a/tests/python/test_tuple_assign.py b/tests/python/test_tuple_assign.py index 83e547887b57a..03dc05bec7d18 100644 --- a/tests/python/test_tuple_assign.py +++ b/tests/python/test_tuple_assign.py @@ -150,7 +150,8 @@ def func(): func() -def _test_unpack_from_vector(): +@test_utils.test(arch=get_host_arch_list()) +def test_unpack_from_vector(): a = ti.field(ti.f32, ()) b = ti.field(ti.f32, ()) c = ti.field(ti.f32, ()) @@ -166,18 +167,6 @@ def func(): assert c[None] == 4 -@test_utils.test(arch=get_host_arch_list()) -def test_unpack_from_vector(): - _test_unpack_from_vector() - - -@test_utils.test(arch=get_host_arch_list(), - real_matrix=True, - real_matrix_scalarize=True) -def test_unpack_from_vector_matrix_scalarize(): - _test_unpack_from_vector() - - @test_utils.test(arch=get_host_arch_list()) def test_unpack_mismatch_vector(): a = ti.field(ti.f32, ()) @@ -207,7 +196,8 @@ def func(): func() -def _test_unpack_mismatch_matrix(): +@test_utils.test(arch=get_host_arch_list()) +def test_unpack_mismatch_matrix(): a = ti.field(ti.f32, ()) b = ti.field(ti.f32, ()) c = ti.field(ti.f32, ()) @@ -222,18 +212,6 @@ def func(): func() -@test_utils.test(arch=get_host_arch_list()) -def test_unpack_mismatch_matrix(): - _test_unpack_mismatch_matrix() - - -@test_utils.test(arch=get_host_arch_list(), - real_matrix=True, - real_matrix_scalarize=True) -def test_unpack_mismatch_matrix_scalarize(): - _test_unpack_mismatch_matrix() - - @test_utils.test(arch=get_host_arch_list()) def test_unpack_from_shape(): a = ti.field(ti.f32, ()) diff --git a/tests/python/test_vector_swizzle.py b/tests/python/test_vector_swizzle.py index 877382aafe8b5..512a9c0a6fda4 100644 --- a/tests/python/test_vector_swizzle.py +++ b/tests/python/test_vector_swizzle.py @@ -26,7 +26,8 @@ def test_vector_swizzle_python(): assert all(z == w.xxxx) -def _test_vector_swizzle_taichi(): +@test_utils.test(debug=True) +def test_vector_swizzle_taichi(): @ti.kernel def foo(): v = ti.math.vec3(0) @@ -49,16 +50,6 @@ def foo(): foo() -@test_utils.test(debug=True) -def test_vector_swizzle_taichi(): - _test_vector_swizzle_taichi() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True, debug=True) -def test_vector_swizzle_taichi_matrix_scalarize(): - _test_vector_swizzle_taichi() - - @test_utils.test(debug=True) def test_vector_swizzle2_taichi(): @ti.kernel @@ -104,7 +95,8 @@ def foo(): foo() -def _test_vector_invalid_swizzle_patterns(): +@test_utils.test() +def test_vector_invalid_swizzle_patterns(): a = ti.math.vec2(1, 2) with pytest.raises(ti.TaichiSyntaxError, @@ -146,17 +138,7 @@ def invalid_xyz(): @test_utils.test() -def test_vector_invalid_swizzle_patterns(): - _test_vector_invalid_swizzle_patterns() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_vector_invalid_swizzle_patterns_real_matrix_scalarize(): - _test_vector_invalid_swizzle_patterns() - - -@test_utils.test(real_matrix=True, real_matrix_scalarize=True) -def test_vector_swizzle_real_matrix_scalarize(): +def test_vector_swizzle3_taichi(): @ti.kernel def foo() -> ti.types.vector(3, ti.i32): v = ti.Vector([1, 2, 3])