Skip to content

Commit 2db3760

Browse files
ricardoV94michaelosthege
authored andcommitted
Don't change constant names in FunctionGraph features
1 parent f4536c3 commit 2db3760

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

pytensor/graph/features.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ class PreserveVariableAttributes(Feature):
753753
"""
754754

755755
def on_change_input(self, fgraph, node, i, r, new_r, reason=None):
756-
if r.name is not None and new_r.name is None:
756+
# Don't change the name of constants
757+
if r.owner and r.name is not None and new_r.name is None:
757758
new_r.name = r.name
758759
if (
759760
getattr(r.tag, "nan_guard_mode_check", False)

pytensor/graph/rewriting/basic.py

-4
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,6 @@ def process_atomic(self, fgraph, c):
588588
sig = c.merge_signature()
589589
other_c = self.atomic_sig_inv.get(sig, None)
590590
if other_c is not None:
591-
# multiple names will clobber each other..
592-
# we adopt convention to keep the last name
593-
if c.name:
594-
other_c.name = c.name
595591
self.scheduled.append([[(c, other_c, "merge")]])
596592
else:
597593
# this is a new constant

0 commit comments

Comments
 (0)