Skip to content

Expose vecdot, vecmat and matvec helpers #1248

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

Closed
wants to merge 1 commit into from

Conversation

twiecki
Copy link
Member

@twiecki twiecki commented Feb 26, 2025

Summary

  • Add vecdot, vecmat, and matvec helpers to match NumPy's API
  • Use existing Blockwise operations but provide more intuitive interface
  • Include comprehensive tests for all three functions

Test plan

  • Added a new TestMatrixVectorOps class with tests for all three functions
  • Tests cover basic usage, batched operations, axis parameter, and error cases
  • All tests pass

Fixes #1237

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://pytensor--1248.org.readthedocs.build/en/1248/

Add three new functions that expose the underlying Blockwise operations:
- vecdot: Computes dot products between vectors with broadcasting
- matvec: Computes matrix-vector products with broadcasting
- vecmat: Computes vector-matrix products with broadcasting

These match the NumPy API for similar operations and complement the
existing matmul function. Each comes with appropriate error handling,
parameter validation, and comprehensive test coverage.

Fixes #1237
@twiecki twiecki closed this Feb 26, 2025
@ricardoV94
Copy link
Member

ricardoV94 commented Feb 26, 2025

It's not terrible. I think some of the checks aren't needed because Blockwise will do them and the tests are a bit overkill perhaps. A bigger question is whether this sort of simple issues are better left for beginners

@twiecki
Copy link
Member Author

twiecki commented Feb 26, 2025

It's not terrible. I think some of the checks aren't needed because Blockwise will do them and the tests are a bit overkill perhaps. A bigger question is whether this sort of simple issues are better left for beginners

Oh I'm surprised, I actually thought there'd be an easier way to implement these. I'll give that as feedback and see what happens.

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 this pull request may close these issues.

Expose vecdot, vecmat and matvec helpers
2 participants