Skip to content

Commit

Permalink
infer_symbols_from_datadescriptor : modification to infer offset (#1525)
Browse files Browse the repository at this point in the history
Small modification to infer offset on top of shape and strides from the
data descriptor (needed in gt4py)
  • Loading branch information
kotsaloscv authored Oct 30, 2024
1 parent 7cb93f2 commit 1d8a693
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dace/frontend/python/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ def infer_symbols_from_datadescriptor(sdfg: SDFG,
desc = sdfg.arrays[arg_name]
if not hasattr(desc, 'shape') or not hasattr(arg_val, 'shape'):
continue
symbolic_values = list(desc.shape) + list(getattr(desc, 'strides', []))
symbolic_values = list(desc.shape) + list(getattr(desc, 'strides', [])) + list(getattr(desc, 'offset', []))
given_values = list(arg_val.shape)
given_strides = []
if hasattr(arg_val, 'strides'):
# NumPy arrays use bytes in strides
factor = getattr(arg_val, 'itemsize', 1)
given_strides = [s // factor for s in arg_val.strides]
given_values += given_strides
given_offset = [o for o in arg_val.offset] if hasattr(arg_val, 'offset') else []
given_values += given_strides + given_offset

for sym_dim, real_dim in zip(symbolic_values, given_values):
repldict = {}
Expand Down

0 comments on commit 1d8a693

Please sign in to comment.