Skip to content
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

Aggressive constprop in LinearAlgebra.wrap #51582

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Aggressive constprop in LinearAlgebra.wrap
  • Loading branch information
jishnub committed Oct 4, 2023
commit 811512c454a96bb382949d7e7637637b01a208a2
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ wrapper_char(A::Hermitian) = A.uplo == 'U' ? 'H' : 'h'
wrapper_char(A::Hermitian{<:Real}) = A.uplo == 'U' ? 'S' : 's'
wrapper_char(A::Symmetric) = A.uplo == 'U' ? 'S' : 's'

function wrap(A::AbstractVecOrMat, tA::AbstractChar)
Base.@constprop :aggressive function wrap(A::AbstractVecOrMat, tA::AbstractChar)
if tA == 'N'
return A
elseif tA == 'T'
Expand Down
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ mul_wrappers = [
m -> adjoint(m),
m -> transpose(m)]

@testset "wrap" begin
f(A) = LinearAlgebra.wrap(A, 'N')
A = ones(1,1)
@test @inferred(f(A)) === A
g(A) = LinearAlgebra.wrap(A, 'T')
@test @inferred(g(A)) === transpose(A)
end

@testset "matrices with zero dimensions" begin
for (dimsA, dimsB, dimsC) in (
((0, 5), (5, 3), (0, 3)),
Expand Down