Simplify elemwise perform method and don't fallback to C-impl #1050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was some convoluted logic in Elemwise perform method to create the python perform callable.
In old times, Theano tried to fallback to the C-impl when the number of operands exceeds those supported by Numpy (32), but this doesn't make sense when the C-backend is not available. I don't think this was even working recently with the C backend around.
Either way, it led to strange errors for users with an invalid C-setup (recently reported by many MacOS users), that read something like
Scratchpad object has no attribute 'ufunc'
. This situation usually arises when PyTensor thinks the C backend is properly setup and fuses many Elemwise operations into largeComposite
that can easily surpass 32 operands. Then it figures out C is not compiling, and ends up having to use the python perform method. This finally, checked the number of operands was less than 32 and if not tried to fallback to the C implementation that had already failed!https://discourse.pymc.io/search?q=object%20has%20no%20attribute%20%27ufunc%27
There is now an informative warning explaining users how it might have arrived at this situation and offering working solutions.
📚 Documentation preview 📚: https://pytensor--1050.org.readthedocs.build/en/1050/