Skip to content

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.

@codecov
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).
Report is 57 commits behind head on master.

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
@ViralBShah ViralBShah merged commit c64c328 into master Jun 2, 2025
4 checks passed
@ViralBShah ViralBShah deleted the jishnub/_mul branch June 2, 2025 15:58
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.

2 participants