-
Notifications
You must be signed in to change notification settings - Fork 217
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
[BUG]: Piecewise not in torch_mappings #639
Comments
I just realised that #433 is a pull request, so I copied the code and used it to add the mappings manually. |
I've added this mapping, which seems to circumvent the error, but I haven't fully tested it yet:
|
Nice! Yeah that should be added to the GitHub pull request. Feel free to suggest that on the PR via the review system and you will be credited as a coauthor of the PR. |
Thanks! I'll add a review comment on the PR. There was another error with
Now, as long as I use a single batch dimension, it works, but multiple batch dimensions fail. I believe this is due to export_torch.py, where _SingleSymPyModule.forward is:
if |
(Just leaving it open until that PR is closed, since there are still some TODO items) |
What happened?
after fitting a pysr module with "greater" as a binary operator, exporting to torch failed with the following error:
KeyError: 'Function Piecewise was not found in Torch function mappings.Please add it to extra_torch_mappings in the format, e.g., {sympy.sqrt: torch.sqrt}.'
I've seen that in #433 Piecewise was added to the mappings, so I'm surprised to see this error.
I did attempt to fix myself, but it didn't work out:
I've tried adding mappings such as:
{sympy.Piecewise: lambda x, y: torch.where(x[1], x[0], y[0])}
but then the same error arises for
sympy.functions.elementary.piecewise.ExprCondPair
and thensympy.logic.boolalg.BooleanTrue
in the end, I added
But even this produced the following error:
KeyError: 'Function ITE was not found in Torch function mappings.Please add it to extra_torch_mappings in the format, e.g., {sympy.sqrt: torch.sqrt}.'
Hopefully, I am missing something obvious?
Version
0.18.4
Operating System
Linux
Package Manager
pip
Interface
Script (i.e.,
python my_script.py
)Relevant log output
No response
Extra Info
No response
The text was updated successfully, but these errors were encountered: