Skip to content

Commit

Permalink
The past is too strong.
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-paul-mueller committed Sep 19, 2024
1 parent 55830cc commit 2204b16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 2 additions & 4 deletions dace/sdfg/sdfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,6 @@ def add_symbol(self, name, stype):
"""
if name in self.symbols:
raise FileExistsError(f'Symbol "{name}" already exists in SDFG')
if name in self.constants_prop:
raise FileExistsError(f'Can not create symbol "{name}", the name is used by a constant.')
if name in self.arrays:
raise FileExistsError(f'Can not create symbol "{name}", the name is used by a data descriptor.')
if name in self._subarrays:
Expand All @@ -764,6 +762,8 @@ def add_symbol(self, name, stype):
raise FileExistsError(f'Can not create symbol "{name}", the name is used by a RedistrArray.')
if not isinstance(stype, dtypes.typeclass):
stype = dtypes.dtype_to_typeclass(stype)
# We do not check for data constant, because there is a link between the constants and
# the data descriptors.
self.symbols[name] = stype

def remove_symbol(self, name):
Expand Down Expand Up @@ -1944,8 +1944,6 @@ def add_datadesc(self, name: str, datadesc: dt.Data, find_new_name=False) -> str

if name in self.arrays:
raise FileExistsError(f'Data descriptor "{name}" already exists in SDFG')
if name in self.constants_prop:
raise FileExistsError(f'Can not create data descriptor "{name}", the name is used by a constant.')
if name in self.symbols:
raise FileExistsError(f'Can not create data descriptor "{name}", the name is used by a symbol.')
if name in self._subarrays:
Expand Down
14 changes: 9 additions & 5 deletions dace/sdfg/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,19 @@ def validate_sdfg(sdfg: 'dace.sdfg.SDFG', references: Set[int] = None, **context
# Ensure that there is a mentioning of constants in either the array or symbol.
for const_name, (const_type, _) in sdfg.constants_prop.items():
if const_name in sdfg.arrays:
if const_type != sdfg.arrays[const_name]:
raise InvalidSDFGError(
if const_type != sdfg.arrays[const_name].dtype:
# This should actually be an error, but there is a lots of code that depends on it.
warnings.warn(
f'Mismatch between constant and data descriptor of "{const_name}", '
f'expected to find "{const_type}" but found "{sdfg.arrays[const_name]}".', sdfg, None)
f'expected to find "{const_type}" but found "{sdfg.arrays[const_name]}".')
elif const_name in sdfg.symbols:
if const_type != sdfg.symbols[const_name]:
raise InvalidSDFGError(
# This should actually be an error, but there is a lots of code that depends on it.
warnings.warn(
f'Mismatch between constant and symobl type of "{const_name}", '
f'expected to find "{const_type}" but found "{sdfg.symbols[const_name]}".', sdfg, None)
f'expected to find "{const_type}" but found "{sdfg.symbols[const_name]}".')
else:
warnings.warn(f'Found constant "{const_name}" that does not refer to an array or a symbol.')

# Validate data descriptors
for name, desc in sdfg._arrays.items():
Expand Down

0 comments on commit 2204b16

Please sign in to comment.