-
-
Notifications
You must be signed in to change notification settings - Fork 235
fix: support GPUs again #4018
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
fix: support GPUs again #4018
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,26 @@ struct MTKParameters{T, I, D, C, N, H} | |||||||||
| constant::C | ||||||||||
| nonnumeric::N | ||||||||||
| caches::H | ||||||||||
|
|
||||||||||
| function MTKParameters{T, I, D, C, N, H}(tunables::T, initials::I, discrete::D, | ||||||||||
| constant::C, nonnumeric::N, | ||||||||||
| caches::H) where {T, I, D, C, N, H} | ||||||||||
| if tunables isa StaticVector{0} | ||||||||||
| tunables = SVector{0, eltype(tunables)}() | ||||||||||
| end | ||||||||||
| if initials isa StaticVector{0} | ||||||||||
| initials = SVector{0, eltype(initials)}() | ||||||||||
| end | ||||||||||
| return new{typeof(tunables), typeof(initials), D, C, N, H}(tunables, initials, | ||||||||||
| discrete, constant, | ||||||||||
| nonnumeric, caches) | ||||||||||
|
Comment on lines
+24
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| end | ||||||||||
| function MTKParameters(tunables::T, initials::I, discrete::D, | ||||||||||
| constant::C, nonnumeric::N, | ||||||||||
| caches::H) where {T, I, D, C, N, H} | ||||||||||
|
Comment on lines
+28
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| return MTKParameters{T, I, D, C, N, H}(tunables, initials, discrete, constant, | ||||||||||
| nonnumeric, caches) | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| end | ||||||||||
| end | ||||||||||
|
|
||||||||||
| """ | ||||||||||
|
|
@@ -138,11 +158,11 @@ function MTKParameters( | |||||||||
| end | ||||||||||
| tunable_buffer = narrow_buffer_type(tunable_buffer; p_constructor) | ||||||||||
| if isempty(tunable_buffer) | ||||||||||
| tunable_buffer = SizedVector{0, Float64}() | ||||||||||
| tunable_buffer = SVector{0, Float64}() | ||||||||||
| end | ||||||||||
| initials_buffer = narrow_buffer_type(initials_buffer; p_constructor) | ||||||||||
| if isempty(initials_buffer) | ||||||||||
| initials_buffer = SizedVector{0, Float64}() | ||||||||||
| initials_buffer = SVector{0, Float64}() | ||||||||||
| end | ||||||||||
| disc_buffer = narrow_buffer_type.(disc_buffer; p_constructor) | ||||||||||
| const_buffer = narrow_buffer_type.(const_buffer; p_constructor) | ||||||||||
|
|
@@ -879,10 +899,10 @@ end | |||||||||
| @generated function Base.getindex( | ||||||||||
| ps::MTKParameters{T, I, D, C, N, H}, idx::Int) where {T, I, D, C, N, H} | ||||||||||
| paths = [] | ||||||||||
| if !(T <: SizedVector{0}) | ||||||||||
| if !(T <: StaticVector{0}) | ||||||||||
| push!(paths, :(ps.tunable)) | ||||||||||
| end | ||||||||||
| if !(I <: SizedVector{0}) | ||||||||||
| if !(I <: StaticVector{0}) | ||||||||||
| push!(paths, :(ps.initials)) | ||||||||||
| end | ||||||||||
| for i in 1:fieldcount(D) | ||||||||||
|
|
@@ -909,10 +929,10 @@ end | |||||||||
| @generated function Base.length(ps::MTKParameters{ | ||||||||||
| T, I, D, C, N, H}) where {T, I, D, C, N, H} | ||||||||||
| len = 0 | ||||||||||
| if !(T <: SizedVector{0}) | ||||||||||
| if !(T <: SVector{0}) | ||||||||||
| len += 1 | ||||||||||
| end | ||||||||||
| if !(I <: SizedVector{0}) | ||||||||||
| if !(I <: SVector{0}) | ||||||||||
| len += 1 | ||||||||||
| end | ||||||||||
| len += fieldcount(D) + fieldcount(C) + fieldcount(N) + fieldcount(H) | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -780,7 +780,7 @@ function get_mtkparameters_reconstructor(srcsys::AbstractSystem, dstsys::Abstrac | |||||||
| # `syms[1]` is always the tunables because `srcsys` will have initials. | ||||||||
| tunable_syms = syms[1] | ||||||||
| tunable_getter = if isempty(tunable_syms) | ||||||||
| Returns(SizedVector{0, Float64}()) | ||||||||
| Returns(SVector{0, Float64}()) | ||||||||
| else | ||||||||
| p_constructor ∘ concrete_getu(srcsys, tunable_syms; eval_expression, eval_module) | ||||||||
| end | ||||||||
|
|
@@ -803,7 +803,7 @@ function get_mtkparameters_reconstructor(srcsys::AbstractSystem, dstsys::Abstrac | |||||||
| end | ||||||||
| p_constructor ∘ concrete_getu(srcsys, initsyms; eval_expression, eval_module) | ||||||||
| else | ||||||||
| Returns(SizedVector{0, Float64}()) | ||||||||
| Returns(SVector{0, Float64}()) | ||||||||
| end | ||||||||
| discs_getter = if isempty(syms[3]) | ||||||||
| Returns(()) | ||||||||
|
|
@@ -923,7 +923,7 @@ function (rip::ReconstructInitializeprob)(srcvalp, dstvalp) | |||||||
| if newp isa MTKParameters | ||||||||
| # and initials portion | ||||||||
| buf, repack, alias = SciMLStructures.canonicalize(SciMLStructures.Initials(), newp) | ||||||||
| if eltype(buf) != T | ||||||||
| if eltype(buf) != T && !(buf isa SVector{0}) | ||||||||
| newbuf = similar(buf, T) | ||||||||
| copyto!(newbuf, buf) | ||||||||
| newp = repack(newbuf) | ||||||||
|
|
@@ -1148,8 +1148,10 @@ function maybe_build_initialization_problem( | |||||||
| if is_split(sys) | ||||||||
| buffer, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), initp) | ||||||||
| initp = repack(floatT.(buffer)) | ||||||||
| buffer, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Initials(), initp) | ||||||||
| initp = repack(floatT.(buffer)) | ||||||||
| if !(initp.initials isa StaticVector{0}) | ||||||||
| buffer, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Initials(), initp) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| initp = repack(floatT.(buffer)) | ||||||||
| end | ||||||||
| elseif initp isa AbstractArray | ||||||||
| if ArrayInterface.ismutable(initp) | ||||||||
| initp′ = similar(initp, floatT) | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶