Skip to content

Commit

Permalink
llvm/execution: Do stricter checks when reshaping synced parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
  • Loading branch information
jvesely committed May 28, 2024
1 parent 54dfe3e commit fc77f48
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions psyneulink/core/llvm/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,16 @@ def _enumerate_recurse(elements):
if "state" in ids:
value = value[-1]

# Try to match the shape of the old value
if hasattr(pnl_value, 'shape'):
try:
value = value.reshape(pnl_value.shape)
except ValueError:
pass
# Reshape to match the shape of the old value.
# Do not try to reshape ragged arrays.
if getattr(pnl_value, 'dtype', object) != object and pnl_value.shape != value.shape:

# Reshape to match numpy 0d arrays and "matrix"
# parameters that are flattened in compiled form
assert pnl_value.shape == () or pnl_param.name == "matrix", \
"{}: {} vs. {}".format(pnl_param.name, pnl_value.shape, value.shape)

value = value.reshape(pnl_value.shape)

pnl_param.set(value, context=context, override=True, compilation_sync=True)

Expand Down

0 comments on commit fc77f48

Please sign in to comment.