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

Special Dispatch for Static Array #264

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Special Dispatch for Static Array #264

merged 1 commit into from
Oct 9, 2023

Conversation

avik-pal
Copy link
Contributor

@avik-pal avik-pal commented Oct 8, 2023

No description provided.

@@ -259,6 +259,11 @@ function init_jacobian(c::AbstractMaybeSparseJacobianCache)
return init_jacobian(__getfield(c, Val(:jac_prototype)), T, c.fx, c.x)
end
init_jacobian(::Nothing, ::Type{T}, fx, x) where {T} = similar(fx, T, length(fx), length(x))
function init_jacobian(::Nothing, ::Type{T}, fx::StaticArray, x::StaticArray) where {T}
# We want to construct a MArray to preserve types
J = StaticArrays.MArray{Tuple{length(fx), length(x)}, T}(undef)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Size so it's inferred?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already compile time rn.

julia> @code_warntype init_jacobian(nothing, Float32, y, x)
MethodInstance for SparseDiffTools.init_jacobian(::Nothing, ::Type{Float32}, ::MVector{30, Float64}, ::SVector{30, Float64})
  from init_jacobian(::Nothing, ::Type{T}, fx::StaticArray, x::StaticArray) where T @ SparseDiffTools /mnt/research/nlsolve/SparseDiffTools.jl/src/highlevel/common.jl:262
Static Parameters
  T = Float32
Arguments
  #self#::Core.Const(SparseDiffTools.init_jacobian)
  _::Core.Const(nothing)
  _::Core.Const(Float32)
  fx::MVector{30, Float64}
  x::SVector{30, Float64}
Locals
  J::MMatrix{30, 30, Float32, 900}
Body::MMatrix{30, 30, Float32, 900}
1%1 = StaticArrays.MArray::Core.Const(MArray)
│   %2 = SparseDiffTools.Tuple::Core.Const(Tuple)
│   %3 = SparseDiffTools.length(fx)::Core.Const(30)
│   %4 = SparseDiffTools.length(x)::Core.Const(30)
│   %5 = Core.apply_type(%2, %3, %4)::Core.Const(Tuple{30, 30})
│   %6 = Core.apply_type(%1, %5, $(Expr(:static_parameter, 1)))::Core.Const(MArray{Tuple{30, 30}, Float32})
│        (J = (%6)(SparseDiffTools.undef))
└──      return J

@codecov
Copy link

codecov bot commented Oct 8, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (659b523) 87.60% compared to head (cf98e97) 87.38%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #264      +/-   ##
==========================================
- Coverage   87.60%   87.38%   -0.22%     
==========================================
  Files          21       21              
  Lines        1226     1229       +3     
==========================================
  Hits         1074     1074              
- Misses        152      155       +3     
Files Coverage Δ
src/SparseDiffTools.jl 100.00% <ø> (ø)
src/highlevel/common.jl 81.81% <0.00%> (-4.73%) ⬇️

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

@ChrisRackauckas ChrisRackauckas merged commit a85a673 into JuliaDiff:master Oct 9, 2023
14 of 16 checks passed
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