Skip to content

Commit

Permalink
Merge branch 'main' into deferred_allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrudPrimrose committed Jan 15, 2025
2 parents 9755810 + 9e4c24b commit f379b3f
Show file tree
Hide file tree
Showing 41 changed files with 1,394 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/general-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7,'3.12']
python-version: ['3.9','3.13']
simplify: [0,1,autoopt]

steps:
Expand Down
8 changes: 5 additions & 3 deletions dace/cli/sdfv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NewCls(cls):
return NewCls


def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: bool = True):
def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: bool = True, compress: bool = True):
"""
View an sdfg in the system's HTML viewer
Expand All @@ -33,6 +33,7 @@ def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: b
served using a basic web server on that port,
blocking the current thread.
:param verbose: Be verbose.
:param compress: Use compression for the temporary file.
"""
# If vscode is open, try to open it inside vscode
if filename is None:
Expand All @@ -41,8 +42,9 @@ def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: b
or 'VSCODE_IPC_HOOK_CLI' in os.environ
or 'VSCODE_GIT_IPC_HANDLE' in os.environ
):
fd, filename = tempfile.mkstemp(suffix='.sdfg')
sdfg.save(filename)
suffix = '.sdfgz' if compress else '.sdfg'
fd, filename = tempfile.mkstemp(suffix=suffix)
sdfg.save(filename, compress=compress)
if platform.system() == 'Darwin':
# Special case for MacOS
os.system(f'open {filename}')
Expand Down
2 changes: 2 additions & 0 deletions dace/codegen/compiled_sdfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ def _construct_args(self, kwargs) -> Tuple[Tuple[Any], Tuple[Any]]:
raise KeyError("Missing program argument \"{}\"".format(a))

else:
if len(sig) > 0:
raise KeyError(f"Missing program arguments: {', '.join(sig)}")
arglist = []
argtypes = []
argnames = []
Expand Down
3 changes: 2 additions & 1 deletion dace/codegen/targets/framecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self, sdfg: SDFG):

# resolve all symbols and constants
# first handle root
sdfg.reset_cfg_list()
self._symbols_and_constants[sdfg.cfg_id] = sdfg.free_symbols.union(sdfg.constants_prop.keys())
# then recurse
for nested, state in sdfg.all_nodes_recursive():
Expand All @@ -66,7 +67,7 @@ def __init__(self, sdfg: SDFG):
# found a new nested sdfg: resolve symbols and constants
result = nsdfg.free_symbols.union(nsdfg.constants_prop.keys())

parent_constants = self._symbols_and_constants[nsdfg._parent_sdfg.cfg_id]
parent_constants = self._symbols_and_constants[nsdfg.parent_sdfg.cfg_id]
result |= parent_constants

# check for constant inputs
Expand Down
24 changes: 15 additions & 9 deletions dace/frontend/python/memlet_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

MemletType = Union[ast.Call, ast.Attribute, ast.Subscript, ast.Name]


if sys.version_info < (3, 8):
_simple_ast_nodes = (ast.Constant, ast.Name, ast.NameConstant, ast.Num)
BytesConstant = ast.Bytes
Expand Down Expand Up @@ -107,6 +106,11 @@ def _fill_missing_slices(das, ast_ndslice, array, indices):
idx = 0
new_idx = 0
has_ellipsis = False

# Count new axes
num_new_axes = sum(1 for dim in ast_ndslice
if (dim is None or (isinstance(dim, (ast.Constant, NameConstant)) and dim.value is None)))

for dim in ast_ndslice:
if isinstance(dim, (str, list, slice)):
dim = ast.Name(id=dim)
Expand Down Expand Up @@ -136,7 +140,7 @@ def _fill_missing_slices(das, ast_ndslice, array, indices):
if has_ellipsis:
raise IndexError('an index can only have a single ellipsis ("...")')
has_ellipsis = True
remaining_dims = len(ast_ndslice) - idx - 1
remaining_dims = len(ast_ndslice) - num_new_axes - idx - 1
for j in range(idx, len(ndslice) - remaining_dims):
ndslice[j] = (0, array.shape[j] - 1, 1)
idx += 1
Expand Down Expand Up @@ -170,7 +174,7 @@ def _fill_missing_slices(das, ast_ndslice, array, indices):
if desc.dtype == dtypes.bool:
# Boolean array indexing
if len(ast_ndslice) > 1:
raise IndexError(f'Invalid indexing into array "{dim.id}". ' 'Only one boolean array is allowed.')
raise IndexError(f'Invalid indexing into array "{dim.id}". Only one boolean array is allowed.')
if tuple(desc.shape) != tuple(array.shape):
raise IndexError(f'Invalid indexing into array "{dim.id}". '
'Shape of boolean index must match original array.')
Expand Down Expand Up @@ -251,9 +255,9 @@ def parse_memlet_subset(array: data.Data,
# Loop over the N dimensions
ndslice, offsets, new_extra_dims, arrdims = _fill_missing_slices(das, ast_ndslice, narray, offsets)
if new_extra_dims and idx != (len(ast_ndslices) - 1):
raise NotImplementedError('New axes only implemented for last ' 'slice')
raise NotImplementedError('New axes only implemented for last slice')
if arrdims and len(ast_ndslices) != 1:
raise NotImplementedError('Array dimensions not implemented ' 'for consecutive subscripts')
raise NotImplementedError('Array dimensions not implemented for consecutive subscripts')
extra_dims = new_extra_dims
subset_array.append(_ndslice_to_subset(ndslice))

Expand All @@ -273,9 +277,10 @@ def parse_memlet_subset(array: data.Data,
def ParseMemlet(visitor,
defined_arrays_and_symbols: Dict[str, Any],
node: MemletType,
parsed_slice: Any = None) -> MemletExpr:
parsed_slice: Any = None,
arrname: Optional[str] = None) -> MemletExpr:
das = defined_arrays_and_symbols
arrname = rname(node)
arrname = arrname or rname(node)
if arrname not in das:
raise DaceSyntaxError(visitor, node, 'Use of undefined data "%s" in memlet' % arrname)
array = das[arrname]
Expand Down Expand Up @@ -304,8 +309,9 @@ def ParseMemlet(visitor,
try:
subset, new_axes, arrdims = parse_memlet_subset(array, node, das, parsed_slice)
except IndexError:
raise DaceSyntaxError(visitor, node, 'Failed to parse memlet expression due to dimensionality. '
f'Array dimensions: {array.shape}, expression in code: {astutils.unparse(node)}')
raise DaceSyntaxError(
visitor, node, 'Failed to parse memlet expression due to dimensionality. '
f'Array dimensions: {array.shape}, expression in code: {astutils.unparse(node)}')

# If undefined, default number of accesses is the slice size
if num_accesses is None:
Expand Down
Loading

0 comments on commit f379b3f

Please sign in to comment.