You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the main selling points of gt4py is that it reports out of bound reads through static analysis of the bounds and index accesses. Below is a case where this analysis fails and out of bound reads happen. We should catch this and throw an error instead. The provided stencil can be used as the basis for a test case.
Repro
in_field and out_field are 3-dimensional arrays.
@gtscript.stencil()deftest_stencil(out_field: FloatField, in_field: FloatField):
# temporary with only one vertical dimensionwithcomputation(FORWARD), interval(-1, None):
temp=2# offset read in the vertical dimensionwithcomputation(FORWARD), interval(-1, None):
out_field=temp[0,0,-1] # <- this reads out of bounds and is not reported
The text was updated successfully, but these errors were encountered:
Bonus points if we manage to emit a warning in the following case where the interval(5, None) restricts the computation to outside the domain (only 2 in the vertical axis) and thus nothing happens. This is valid code. Would just be nice to emit a warning.
fromgt4py.cartesian.gtscriptimportPARALLEL, computation, interval, stencilfromndsl.dsl.typingimportFloatFieldfromndsl.quantityimportQuantityimportnumpyasnpbackend="dace:cpu"nx=3ny=4nz=2# <- vertical domain size is 2 onlyshape= (nx, ny, nz)
qty_out=Quantity(
data=np.zeros([nx, ny, nz]), dims=["I", "J", "K"], units="m", gt4py_backend=backend
)
arr=np.indices(shape, dtype=float).sum(
axis=0
) # Value of each entry is sum of the I and J index at each pointqty_in=Quantity(data=arr, dims=["I", "J", "K"], units="m", gt4py_backend=backend)
@stencil(backend=backend, rebuild=True)defcopy_stencil(input_field: FloatField, output_field: FloatField):
withcomputation(PARALLEL), interval(5, None): # <- interval starts outside the domainoutput_field=input_fieldcopy_stencil(qty_in, qty_out)
We figured that in dace orchestration, the current out-of-bounds read/write analysis comes too late in the pipeline, leaving people with (cryptic) SDFG validation errors instead of (clean) extent analysis error messages. That only happens in orchestration because only in orchestration we freeze origin/domain with the stencil. In GridTools workflow, origin and domain are a call arguments and thus we can only check this at call time. And apparently we always check this at call time, even in orchestration workflow. This leads orchestration workflows to fail (at build time) even before we get to the analysis (at call time).
Description
One of the main selling points of gt4py is that it reports out of bound reads through static analysis of the bounds and index accesses. Below is a case where this analysis fails and out of bound reads happen. We should catch this and throw an error instead. The provided stencil can be used as the basis for a test case.
Repro
in_field
andout_field
are 3-dimensional arrays.The text was updated successfully, but these errors were encountered: