Skip to content

Commit

Permalink
Merge pull request #71 from tjjarvinen/dev-assemble
Browse files Browse the repository at this point in the history
add new assemble
  • Loading branch information
wcwitt committed Sep 22, 2023
2 parents 01f9a7f + 08cd3c9 commit cd91b19
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/assemble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,26 @@ function assemble_threadsx(data::AbstractVector{<:AbstractData}, basis)
@info " - Assembly completed."
return A, Y, W
end


function assemble_new(data::AbstractArray, basis; batch_size=1, kwargs...)
W = Threads.@spawn ACEfit.assemble_weights_new(data; kwargs...)
raw_data = @showprogress desc="Assembly progress:" pmap( data; batch_size=batch_size ) do d
A = ACEfit.feature_matrix(d, basis; kwargs...)
Y = ACEfit.target_vector(d; kwargs...)
(A, Y)
end
A = [ a[1] for a in raw_data ]
Y = [ a[2] for a in raw_data ]

A_final = reduce(vcat, A)
Y_final = reduce(vcat, Y)
return A_final, Y_final, fetch(W)
end

function assemble_weights_new(data::AbstractArray; kwargs...)
w = map( data ) do d
ACEfit.weight_vector(d; kwargs...)
end
return reduce(vcat, w)
end

0 comments on commit cd91b19

Please sign in to comment.