128
128
function split_into_buffers (raw:: AbstractArray , buf; recurse = true )
129
129
idx = 1
130
130
function _helper (buf_v; recurse = true )
131
- if eltype (buf_v) isa AbstractArray && recurse
131
+ if eltype (buf_v) <: AbstractArray && recurse
132
132
return _helper .(buf_v; recurse = false )
133
133
else
134
134
res = reshape (raw[idx: (idx + length (buf_v) - 1 )], size (buf_v))
@@ -139,6 +139,19 @@ function split_into_buffers(raw::AbstractArray, buf; recurse = true)
139
139
return Tuple (_helper (buf_v; recurse) for buf_v in buf)
140
140
end
141
141
142
+ function update_tuple_of_buffers (raw:: AbstractArray , buf)
143
+ idx = 1
144
+ function _helper (buf_v)
145
+ if eltype (buf_v) <: AbstractArray
146
+ _helper .(buf_v)
147
+ else
148
+ copyto! (buf_v, view (raw, idx: (idx + length (buf_v) - 1 )))
149
+ idx += length (buf_v)
150
+ end
151
+ end
152
+ _helper .(buf)
153
+ end
154
+
142
155
SciMLStructures. isscimlstructure (:: MTKParameters ) = true
143
156
144
157
SciMLStructures. ismutablescimlstructure (:: MTKParameters ) = true
@@ -151,7 +164,7 @@ for (Portion, field) in [(SciMLStructures.Tunable, :tunable)
151
164
repack = let as_vector = as_vector, p = p
152
165
function (new_val)
153
166
if new_val != = as_vector
154
- p. $ field = split_into_buffers (new_val, p.$ field)
167
+ update_tuple_of_buffers (new_val, p.$ field)
155
168
end
156
169
if p. dependent_update_iip != = nothing
157
170
p. dependent_update_iip (ArrayPartition (p. dependent), p... )
0 commit comments