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

add new assemble #71

Merged
merged 1 commit into from
Sep 22, 2023
Merged
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
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
Loading