Skip to content

Commit

Permalink
Fix type inference for scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun committed Oct 28, 2024
1 parent bceaf39 commit c7f4694
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion dace/codegen/tools/type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import numpy as np
import ast
from dace import dtypes
from dace import data, dtypes
from dace import symbolic
from dace.codegen import cppunparse
from dace.symbolic import symbol, SymExpr, symstr
Expand Down Expand Up @@ -286,6 +286,8 @@ def _Name(t, symbols, inferred_symbols):
inferred_type = dtypes.typeclass(inferred_type.type)
elif isinstance(inferred_type, symbolic.symbol):
inferred_type = inferred_type.dtype
elif isinstance(inferred_type, data.Data):
inferred_type = inferred_type.dtype
elif t_id in inferred_symbols:
inferred_type = inferred_symbols[t_id]
return inferred_type
Expand Down
8 changes: 4 additions & 4 deletions dace/frontend/python/newast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,19 +1489,19 @@ def _symbols_from_params(self, params: List[Tuple[str, Union[str, dtypes.typecla
else:
values = str(val).split(':')
if len(values) == 1:
result[name] = symbolic.symbol(name, infer_expr_type(values[0], {**self.globals, **dyn_inputs}))
result[name] = symbolic.symbol(name, infer_expr_type(values[0], {**self.defined, **dyn_inputs}))
elif len(values) == 2:
result[name] = symbolic.symbol(
name,
dtypes.result_type_of(infer_expr_type(values[0], {
**self.globals,
**self.defined,
**dyn_inputs
}), infer_expr_type(values[1], {
**self.globals,
**self.defined,
**dyn_inputs
})))
elif len(values) == 3:
result[name] = symbolic.symbol(name, infer_expr_type(values[0], {**self.globals, **dyn_inputs}))
result[name] = symbolic.symbol(name, infer_expr_type(values[0], {**self.defined, **dyn_inputs}))
else:
raise DaceSyntaxError(
self, None, "Invalid number of arguments in a range iterator. "
Expand Down

0 comments on commit c7f4694

Please sign in to comment.