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

Enhance edge and vertex weights for HyPar optimizer #43

Merged
merged 8 commits into from
Nov 3, 2023
Merged
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/Optimizers/KaHyPar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ using KaHyPar
imbalance::Float32 = 0.03
stop::Function = <=(2) ∘ length ∘ Base.Fix1(getfield, :args)
configuration::Union{Nothing,Symbol,String} = nothing
edge_weight_scaling::Function = (ind_size) -> 1000 * Int(round(log2(ind_size)))
vertex_weight_scaling::Function = (prod_size) -> 1000 * Int(round(log2(prod_size)))
jofrevalles marked this conversation as resolved.
Show resolved Hide resolved
end

function EinExprs.einexpr(config::HyPar, path)
Expand All @@ -21,8 +23,8 @@ function EinExprs.einexpr(config::HyPar, path)
incidence_matrix = sparse(I, J, V)

# NOTE indices in `inds` should be in the same order as unique indices appear by iterating on `path.args` because `∪` retains order
edge_weights = map(Base.Fix1(size, path), inds)
vertex_weights = ones(Int, length(path.args))
edge_weights = map(ind -> config.edge_weight_scaling(size(path, ind)), inds)
mofeing marked this conversation as resolved.
Show resolved Hide resolved
vertex_weights = map(tensor -> config.vertex_weight_scaling(prod(size(tensor))), path.args)
mofeing marked this conversation as resolved.
Show resolved Hide resolved

hypergraph = KaHyPar.HyperGraph(incidence_matrix, vertex_weights, edge_weights)

Expand Down