Skip to content

Missing rewrite softplus(log(x)) -> log1p(x) #1451

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

Open
lciti opened this issue Jun 6, 2025 · 0 comments · May be fixed by #1452
Open

Missing rewrite softplus(log(x)) -> log1p(x) #1451

lciti opened this issue Jun 6, 2025 · 0 comments · May be fixed by #1452

Comments

@lciti
Copy link

lciti commented Jun 6, 2025

Description

PyTensor is missing this simple rewrite:

import pytensor.tensor as pt
from pytensor.graph import rewrite_graph

x = pt.scalar("x")
out = pt.softplus(pt.log(x))
new_out = rewrite_graph(out, include=("canonicalize", "stabilize", "specialize"))
new_out.dprint()

I am ready to propose a PR that addresses this issue.

I could also extend it to cover the case softplus(-log(x)) -> log1p(1/x). However I have noticed that even the simple exp(-log(x)) -> 1/x is missing, so I wonder if there is an underlying reason to avoid such simplifications, that I am not aware of.

@lciti lciti linked a pull request Jun 6, 2025 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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant