Skip to content

Commit 557caec

Browse files
committed
fix: use constant_fold instead of manual eval
1 parent 28a670b commit 557caec

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pymc_experimental/model/transforms/autoreparam.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
model_from_fgraph,
2020
model_named,
2121
)
22-
from pymc.pytensorf import toposort_replace
22+
from pymc.pytensorf import constant_fold, toposort_replace
2323
from pytensor.graph.basic import Apply, Variable
2424
from pytensor.tensor.random.op import RandomVariable
2525

@@ -176,12 +176,8 @@ def vip_reparam_node(
176176
) -> Tuple[ModelDeterministic, ModelNamed]:
177177
if not isinstance(node.op, RandomVariable | SymbolicRandomVariable):
178178
raise TypeError("Op should be RandomVariable type")
179-
_, size, *_ = node.inputs
180-
eval_size = size.eval()
181-
if eval_size is not None:
182-
rv_shape = tuple(eval_size)
183-
else:
184-
rv_shape = ()
179+
rv = node.default_output()
180+
[rv_shape] = constant_fold([rv.shape], raise_if_not_constant=False)
185181
lam_name = f"{name}::lam_logit__"
186182
_log.debug(f"Creating {lam_name} with shape of {rv_shape}")
187183
logit_lam_ = pytensor.shared(

0 commit comments

Comments
 (0)