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.
Add dot operation to xtensor module
This PR adds support for the dot product operation in the xtensor module. The implementation includes:
New dot method
.dot()
method toXTensorVariable
inpytensor/xtensor/type.py
to provide a consistent interface for dot operations, similar to other math functions.Rewrite rule for dot
pytensor/xtensor/rewriting/math.py
that converts theXDot
operation to a tensor-based dot operation usingtensordot
. This rule handles dimension alignment and contraction correctly.Import of math rewriting module
pytensor/xtensor/rewriting/__init__.py
to import the math rewriting module, ensuring that the dot rewrite rule is registered and available during the rewrite pass.Unit tests
test_dot()
intests/xtensor/test_math.py
to verify the basic functionality of the dot operation, including matrix-matrix and matrix-vector dot products, proper dimension handling, and shape validation.These changes ensure that the xtensor module now supports dot operations, maintaining consistency with other math functions and enabling proper dimension handling for tensor contractions.
📚 Documentation preview 📚: https://pytensor--1450.org.readthedocs.build/en/1450/