Skip to content

Commit

Permalink
Verbose current dace:X bug around while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianDeconinck committed Mar 15, 2024
1 parent d956202 commit 899a5da
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def test_generation(name, backend):
@pytest.mark.parametrize("backend", ALL_BACKENDS)
def test_lazy_stencil(backend):
@gtscript.lazy_stencil(backend=backend)
def definition(field_a: gtscript.Field[np.float_], field_b: gtscript.Field[np.float_]):
def definition(
field_a: gtscript.Field[np.float_], field_b: gtscript.Field[np.float_]
):
with computation(PARALLEL), interval(...):
field_a = field_b

Expand Down Expand Up @@ -148,7 +150,9 @@ def test_stage_merger_induced_interval_block_reordering(backend):
)

@gtscript.stencil(backend=backend)
def stencil(field_in: gtscript.Field[np.float_], field_out: gtscript.Field[np.float_]):
def stencil(
field_in: gtscript.Field[np.float_], field_out: gtscript.Field[np.float_]
):
with computation(BACKWARD):
with interval(-2, -1): # block 1
field_out = field_in
Expand Down Expand Up @@ -293,7 +297,9 @@ def copy_2to3(
with computation(FORWARD), interval(...):
outp[0, 0, 0] = inp

inp_f = gt_storage.from_array(np.random.randn(10, 10), aligned_index=(0, 0), backend=backend)
inp_f = gt_storage.from_array(
np.random.randn(10, 10), aligned_index=(0, 0), backend=backend
)
outp_f = gt_storage.from_array(
np.random.randn(10, 10, 10), aligned_index=(0, 0, 0), backend=backend
)
Expand Down Expand Up @@ -478,7 +484,9 @@ def stencil(
full_shape, backend=backend, aligned_index=aligned_index, dtype=INT32_VEC2
)

gtscript.stencil(definition=stencil, backend=backend)(input_field, output_field, index := 1)
gtscript.stencil(definition=stencil, backend=backend)(
input_field, output_field, index := 1
)
assert output_field[0, 0, 0, index] == 1


Expand Down Expand Up @@ -575,7 +583,9 @@ def k_to_ijk(outp: Field[np.float64], inp: Field[gtscript.K, np.float64]):
inp = storage_utils.cpu_copy(inp)
outp = storage_utils.cpu_copy(outp)
np.testing.assert_allclose(data, inp)
np.testing.assert_allclose(np.broadcast_to(data[2:], shape=(2, 2, 8)), outp[:, :, 1:-1])
np.testing.assert_allclose(
np.broadcast_to(data[2:], shape=(2, 2, 8)), outp[:, :, 1:-1]
)
np.testing.assert_allclose(0.0, outp[:, :, 0])
np.testing.assert_allclose(0.0, outp[:, :, -1])

Expand Down Expand Up @@ -675,6 +685,7 @@ def test_K_offset_write_conditional(backend):
# While loop have a bug in `dace:X` backends where
# the read-connector is used which means you can never
# update the field in a while.
# Logged in: https://github.com/GridTools/gt4py/issues/1496
if backend.startswith("dace") or backend == "cuda":
pytest.skip("DaCe backends have a bug when handling while loop.")

Expand All @@ -683,7 +694,9 @@ def test_K_offset_write_conditional(backend):
K_values = arraylib.arange(start=40, stop=44)

@gtscript.stencil(backend=backend)
def column_physics_conditional(A: Field[np.float64], B: Field[np.float64], scalar: np.float64):
def column_physics_conditional(
A: Field[np.float64], B: Field[np.float64], scalar: np.float64
):
with computation(BACKWARD), interval(1, None):
if A > 0 and B > 0:
A[0, 0, -1] = scalar
Expand Down

0 comments on commit 899a5da

Please sign in to comment.