Skip to content

Commit

Permalink
Modified how fill() works, it now also accepts non variables.
Browse files Browse the repository at this point in the history
This changes makes it possible that the `fill()` function accepts variables.
However, this particular commit only allows variables that where passed as arguments, at least in some sense, see the discussion of the issue.

This is a first step to address issue [spcl#1389](spcl#1389).
  • Loading branch information
philip-paul-mueller committed Nov 1, 2023
1 parent 0d09081 commit 59fe6d0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dace/frontend/python/replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -4234,6 +4234,10 @@ def _ndarray_copy(pv: ProgramVisitor, sdfg: SDFG, state: SDFGState, arr: str) ->
@oprepo.replaces_method('View', 'fill')
def _ndarray_fill(pv: ProgramVisitor, sdfg: SDFG, state: SDFGState, arr: str, value: Number) -> str:
if not isinstance(value, (Number, np.bool_)):
pass # Litteral numbers passed as arguments
elif isinstance(value, str) and isinstance(sdfg.arrays.get(value, None), data.Scalar):
pass # Scalars inside the sdfg (is this safe?)
else:
raise mem_parser.DaceSyntaxError(pv, None, "Fill value {f} must be a number!".format(f=value))
return _elementwise(pv, sdfg, state, "lambda x: {}".format(value), arr, arr)

Expand Down

0 comments on commit 59fe6d0

Please sign in to comment.