mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-03 05:01:25 +00:00
Simplify and fix template parameters
This commit is contained in:
@@ -9,41 +9,6 @@
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
template <typename ComputeDataType>
|
||||
void sinkhorn_knopp_ref_single_iter(HostTensor<ComputeDataType>& c_n_n,
|
||||
HostTensor<ComputeDataType>& acc_n)
|
||||
{
|
||||
const index_t input_n = acc_n.get_length(0);
|
||||
|
||||
// Sum and scale rowwise
|
||||
for(index_t i = 0; i < input_n; ++i)
|
||||
{
|
||||
acc_n(i) = 0;
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
acc_n(i) += c_n_n(i, j);
|
||||
}
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
c_n_n(i, j) /= acc_n(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Repeat columnwise
|
||||
for(index_t i = 0; i < input_n; ++i)
|
||||
{
|
||||
acc_n(i) = 0;
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
acc_n(i) += c_n_n(j, i);
|
||||
}
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
c_n_n(j, i) /= acc_n(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename XDataType, typename ComputeDataType, typename YDataType>
|
||||
void sinkhorn_knopp_ref(const HostTensor<XDataType>& x_n_n,
|
||||
HostTensor<YDataType>& y_n_n,
|
||||
@@ -65,7 +30,33 @@ void sinkhorn_knopp_ref(const HostTensor<XDataType>& x_n_n,
|
||||
// Iterate normalization on rows and columns
|
||||
for(auto it = 0; it < n_iter; ++it)
|
||||
{
|
||||
sinkhorn_knopp_ref_single_iter(c_n_n, c_n_n);
|
||||
// Sum and scale rowwise
|
||||
for(index_t i = 0; i < input_n; ++i)
|
||||
{
|
||||
acc_n(i) = 0;
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
acc_n(i) += c_n_n(i, j);
|
||||
}
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
c_n_n(i, j) /= acc_n(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Repeat columnwise
|
||||
for(index_t i = 0; i < input_n; ++i)
|
||||
{
|
||||
acc_n(i) = 0;
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
acc_n(i) += c_n_n(j, i);
|
||||
}
|
||||
for(index_t j = 0; j < input_n; ++j)
|
||||
{
|
||||
c_n_n(j, i) /= acc_n(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy and cast to output type
|
||||
|
||||
Reference in New Issue
Block a user