From 5354e4df571ea8d928af27460f9aaf72aa436277 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Fri, 8 Sep 2023 16:36:39 +0200 Subject: [PATCH 1/5] [dace] Add support for floordiv --- .../program_processors/runners/dace_iterator/itir_to_tasklet.py | 1 + .../feature_tests/ffront_tests/test_execution.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gt4py/next/program_processors/runners/dace_iterator/itir_to_tasklet.py b/src/gt4py/next/program_processors/runners/dace_iterator/itir_to_tasklet.py index 875a23353b..d301c3e3cf 100644 --- a/src/gt4py/next/program_processors/runners/dace_iterator/itir_to_tasklet.py +++ b/src/gt4py/next/program_processors/runners/dace_iterator/itir_to_tasklet.py @@ -96,6 +96,7 @@ def itir_type_as_dace_type(type_: next_typing.Type): "minus": "({} - {})", "multiplies": "({} * {})", "divides": "({} / {})", + "floordiv": "({} // {})", "eq": "({} == {})", "not_eq": "({} != {})", "less": "({} < {})", diff --git a/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_execution.py b/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_execution.py index 9f284f4041..b44cbb8181 100644 --- a/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_execution.py +++ b/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_execution.py @@ -781,8 +781,6 @@ def program_domain(a: cases.IField, out: cases.IField): def test_domain_input_bounds(cartesian_case): if cartesian_case.backend in [gtfn_cpu.run_gtfn, gtfn_cpu.run_gtfn_imperative]: pytest.xfail("FloorDiv not fully supported in gtfn.") - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Not supported in DaCe backend: type inference failure") lower_i = 1 upper_i = 10 From bdb41bc19418c5e8276515252762fbfd22dd31b4 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Fri, 8 Sep 2023 17:07:21 +0200 Subject: [PATCH 2/5] [dace] Enable test for math built-in execution --- .../feature_tests/ffront_tests/test_math_builtin_execution.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_builtin_execution.py b/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_builtin_execution.py index b484fc6f31..9ceab7f2d0 100644 --- a/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_builtin_execution.py +++ b/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_builtin_execution.py @@ -117,8 +117,6 @@ def make_builtin_field_operator(builtin_name: str): @pytest.mark.parametrize("builtin_name, inputs", math_builtin_test_data()) def test_math_function_builtins_execution(cartesian_case, builtin_name: str, inputs): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") if builtin_name == "gamma": # numpy has no gamma function ref_impl: Callable = np.vectorize(math.gamma) From c4a3def0e3cbab72d766a5949a05dee3d58df185 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Fri, 8 Sep 2023 17:13:57 +0200 Subject: [PATCH 3/5] [dace] Enable test for math built-in unary functions --- .../ffront_tests/test_math_unary_builtins.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_unary_builtins.py b/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_unary_builtins.py index 6c7dbee855..23afc707b0 100644 --- a/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_unary_builtins.py +++ b/tests/next_tests/integration_tests/feature_tests/ffront_tests/test_math_unary_builtins.py @@ -60,9 +60,6 @@ def arithmetic(inp1: cases.IFloatField, inp2: cases.IFloatField) -> gtx.Field[[I def test_power(cartesian_case): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") - @gtx.field_operator def pow(inp1: cases.IField) -> cases.IField: return inp1**2 @@ -74,7 +71,6 @@ def test_floordiv(cartesian_case): if cartesian_case.backend in [ gtfn_cpu.run_gtfn, gtfn_cpu.run_gtfn_imperative, - dace_iterator.run_dace_iterator, ]: pytest.xfail( "FloorDiv not yet supported." @@ -201,9 +197,6 @@ def not_fieldop(inp1: cases.IBoolField) -> cases.IBoolField: def test_basic_trig(cartesian_case): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") - @gtx.field_operator def basic_trig_fieldop(inp1: cases.IFloatField, inp2: cases.IFloatField) -> cases.IFloatField: return sin(cos(inp1)) - sinh(cosh(inp2)) + tan(inp1) - tanh(inp2) @@ -219,9 +212,6 @@ def basic_trig_fieldop(inp1: cases.IFloatField, inp2: cases.IFloatField) -> case def test_exp_log(cartesian_case): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") - @gtx.field_operator def exp_log_fieldop(inp1: cases.IFloatField, inp2: cases.IFloatField) -> cases.IFloatField: return log(inp1) - exp(inp2) @@ -232,9 +222,6 @@ def exp_log_fieldop(inp1: cases.IFloatField, inp2: cases.IFloatField) -> cases.I def test_roots(cartesian_case): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") - @gtx.field_operator def roots_fieldop(inp1: cases.IFloatField, inp2: cases.IFloatField) -> cases.IFloatField: return sqrt(inp1) - cbrt(inp2) @@ -245,9 +232,6 @@ def roots_fieldop(inp1: cases.IFloatField, inp2: cases.IFloatField) -> cases.IFl def test_is_values(cartesian_case): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") - @gtx.field_operator def is_isinf_fieldop(inp1: cases.IFloatField) -> cases.IBoolField: return isinf(inp1) @@ -274,9 +258,6 @@ def is_isfinite_fieldop(inp1: cases.IFloatField) -> cases.IBoolField: def test_rounding_funs(cartesian_case): - if cartesian_case.backend == dace_iterator.run_dace_iterator: - pytest.xfail("Bug in type inference with math builtins, breaks dace backend.") - @gtx.field_operator def rounding_funs_fieldop( inp1: cases.IFloatField, inp2: cases.IFloatField From 6828e4e1f1ee45db8111d6db72f6bac1104a9d9c Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Mon, 11 Sep 2023 08:44:47 +0200 Subject: [PATCH 4/5] [dace] Enable test --- .../iterator_tests/test_with_toy_connectivity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py b/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py index b0d04d4379..64d6062af3 100644 --- a/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py +++ b/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py @@ -169,9 +169,9 @@ def first_vertex_neigh_of_first_edge_neigh_of_cells(in_vertices): def test_first_vertex_neigh_of_first_edge_neigh_of_cells_fencil( - program_processor_no_dace_exec, lift_mode + program_processor, lift_mode ): - program_processor, validate = program_processor_no_dace_exec + program_processor, validate = program_processor inp = vertex_index_field() out = gtx.np_as_located_field(Cell)(np.zeros([9], dtype=inp.dtype)) ref = np.asarray(list(v2e_arr[c[0]][0] for c in c2e_arr)) From 98ac1004f12eb4dcfcc8494fb305f0bd0efa8d1d Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Mon, 11 Sep 2023 09:29:13 +0200 Subject: [PATCH 5/5] [dace] Fix formatting --- .../iterator_tests/test_with_toy_connectivity.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py b/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py index 64d6062af3..ded65bceaa 100644 --- a/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py +++ b/tests/next_tests/integration_tests/multi_feature_tests/iterator_tests/test_with_toy_connectivity.py @@ -168,9 +168,7 @@ def first_vertex_neigh_of_first_edge_neigh_of_cells(in_vertices): return deref(shift(E2V, 0)(shift(C2E, 0)(in_vertices))) -def test_first_vertex_neigh_of_first_edge_neigh_of_cells_fencil( - program_processor, lift_mode -): +def test_first_vertex_neigh_of_first_edge_neigh_of_cells_fencil(program_processor, lift_mode): program_processor, validate = program_processor inp = vertex_index_field() out = gtx.np_as_located_field(Cell)(np.zeros([9], dtype=inp.dtype))