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

Binarize Dice Distance for Dense Inputs #2370

Merged
merged 16 commits into from
Jul 10, 2024
Merged
28 changes: 5 additions & 23 deletions cpp/include/raft/distance/detail/distance.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -279,32 +279,14 @@ void distance_impl(raft::resources const& handle,
true,
stream,
false,
raft::identity_op(),
raft::nz_op(),
raft::add_op());
} else {
y_norm += m;
raft::linalg::reduce(x_norm,
x,
k,
m,
(AccT)0,
is_row_major,
true,
stream,
false,
raft::identity_op(),
raft::add_op());
raft::linalg::reduce(y_norm,
y,
k,
n,
(AccT)0,
is_row_major,
true,
stream,
false,
raft::identity_op(),
raft::add_op());
raft::linalg::reduce(
x_norm, x, k, m, (AccT)0, is_row_major, true, stream, false, raft::nz_op(), raft::add_op());
raft::linalg::reduce(
y_norm, y, k, n, (AccT)0, is_row_major, true, stream, false, raft::nz_op(), raft::add_op());
}

ops::dice_distance_op<DataT, AccT, IdxT> distance_op{};
Expand Down
5 changes: 4 additions & 1 deletion cpp/include/raft/distance/detail/distance_ops/dice.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ struct dice_distance_op {
return Policy::SmemSize + ((Policy::Mblk + Policy::Nblk) * sizeof(DataT));
}

DI void core(AccT& acc, DataT& x, DataT& y) const { acc += x * y; };
DI void core(AccT& acc, DataT& x, DataT& y) const
{
acc += (x != DataT(0) ? DataT(1) : DataT(0)) * (y != DataT(0) ? DataT(1) : DataT(0));
};

template <typename Policy>
DI void epilog(AccT acc[Policy::AccRowsPerTh][Policy::AccColsPerTh],
Expand Down
Loading