ec436095dd
Book-CI / test (macos-latest) (push) Has been cancelled
Book-CI / test (ubuntu-latest) (push) Has been cancelled
Book-CI / test (windows-latest) (push) Has been cancelled
Release Fake Tag / publish (push) Has been cancelled
Deploy / deploy (macos-latest) (push) Has been cancelled
Deploy / deploy (ubuntu-latest) (push) Has been cancelled
Deploy / deploy (windows-latest) (push) Has been cancelled
Release to PyPI / Build & publish sglang-kt (push) Has been cancelled
Release to PyPI / Build kt-kernel (Python 3.11) (push) Has been cancelled
Release to PyPI / Build kt-kernel (Python 3.12) (push) Has been cancelled
Release to PyPI / Publish kt-kernel to PyPI (push) Has been cancelled
23 lines
587 B
C++
23 lines
587 B
C++
#ifndef CPUINFER_REDUCE_HPP
|
|
#define CPUINFER_REDUCE_HPP
|
|
|
|
#include <cmath>
|
|
|
|
template <typename T>
|
|
void reduce_sum(T** data, size_t data_groups_count, size_t begin, size_t end) {
|
|
if (data_groups_count <= 1) {
|
|
} else if (data_groups_count == 2) {
|
|
for (size_t i = begin; i < end; i++) {
|
|
data[0][i] += data[1][i];
|
|
}
|
|
} else {
|
|
int part1 = data_groups_count / 2;
|
|
reduce_sum(data, part1, begin, end);
|
|
reduce_sum(data + part1, data_groups_count - part1, begin, end);
|
|
for (size_t i = begin; i < end; i++) {
|
|
data[0][i] += data[part1][i];
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |