Skip to content

Commit 9c79f9a

Browse files
committed
Use python implementation for constant_folding Ops
1 parent c5a8f00 commit 9c79f9a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pytensor/tensor/rewriting/basic.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,15 @@ def unconditional_constant_folding(fgraph, node):
11011101
storage_map[o] = [None]
11021102
compute_map[o] = [False]
11031103

1104-
thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
1105-
required = thunk()
1104+
try:
1105+
thunk = node.op.make_thunk(
1106+
node, storage_map, compute_map, no_recycling=[], impl="py"
1107+
)
1108+
required = thunk()
1109+
except NotImplementedError:
1110+
# Not all Ops have a python implementation
1111+
thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
1112+
required = thunk()
11061113

11071114
# A node whose inputs are all provided should always return successfully
11081115
assert not required

0 commit comments

Comments
 (0)