Skip to content

Size check in 2-argument mul #1315

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
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Size check in 2-argument mul #1315

wants to merge 4 commits into from

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Apr 26, 2025

This PR adds a size check in the 2-argument mul, so that now the destination array is allocated only if the sizes of the arguments are compatible with matrix multiplication. This means that we don't allocate in case of an error anymore.

The performance for small-matrix multiplication seems largely similar (it's comparable to #1310, and seems identical within the noise limit):

julia> A = [1 2; 3 4];

julia> @btime $A * $A;
  42.304 ns (2 allocations: 112 bytes) # before this PR
  44.203 ns (2 allocations: 112 bytes) # this PR

We also redirect the generic mul to _mul now, which is the function that defines the multiplication code. This allows us to reuse the _mul definition elsewhere without having to repeat code. Currently, this is mainly necessary in the Bidiagonal-triangular multiplications.

Copy link

codecov bot commented Apr 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.74%. Comparing base (e4e8c19) to head (f2c5004).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1315      +/-   ##
==========================================
+ Coverage   93.72%   93.74%   +0.01%     
==========================================
  Files          34       34              
  Lines       15692    15694       +2     
==========================================
+ Hits        14708    14712       +4     
+ Misses        984      982       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jishnub jishnub changed the title Size check in mul Size check in 2-argument mul Apr 26, 2025
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.

1 participant