Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overwriting registered rewrite #1070

Open
ricardoV94 opened this issue Nov 6, 2024 · 0 comments · May be fixed by #1119
Open

Allow overwriting registered rewrite #1070

ricardoV94 opened this issue Nov 6, 2024 · 0 comments · May be fixed by #1119

Comments

@ricardoV94
Copy link
Member

Description

PyTensor raises if you try to register the same rewrite twice. This is annoying when developing rewrites in an interactive environment, forcing constant restart of the interpreter. Would be nice to add an overwrite_existing flag to allow replacing the pre-existing rewrite by the new one. The logic of how rewrites are registered is pretty messy though, so it may require some work.

from pytensor.graph.rewriting.basic import node_rewriter
from pytensor.tensor.rewriting.basic import register_canonicalize

@node_rewriter(None)
def my_rewrite():
    pass

register_canonicalize(my_rewrite)
register_canonicalize(my_rewrite)  # ValueError: The tag 'my_rewrite' is already present in the database.
@AdvH039 AdvH039 linked a pull request Dec 12, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant