Skip to content

Commit

Permalink
llvm/execution: Retrieve PNL parameter value only once
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 ad3b5cd commit 54dfe3e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions psyneulink/core/llvm/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ def _enumerate_recurse(elements):

# Handle PNL parameters
pnl_param = getattr(component.parameters, attribute)
pnl_value = pnl_param.get(context=context)

# Use ._get to retrieve underlying numpy arrays
# (.get will extract a scalar if originally set as a scalar)
pnl_value = pnl_param._get(context=context)

# Recurse if the value is a PNL object with its own parameters
if hasattr(pnl_value, 'parameters'):
Expand All @@ -204,13 +207,9 @@ def _enumerate_recurse(elements):
value = value[-1]

# Try to match the shape of the old value
# Use ._get to retrieve underlying numpy arrays
# (.get will extract a scalar if originally set
# as a scalar)
old_value = pnl_param._get(context)
if hasattr(old_value, 'shape'):
if hasattr(pnl_value, 'shape'):
try:
value = value.reshape(old_value.shape)
value = value.reshape(pnl_value.shape)
except ValueError:
pass

Expand Down

0 comments on commit 54dfe3e

Please sign in to comment.