fix for-loop bounderies

This commit is contained in:
enum-class 2024-03-06 08:25:50 +08:00
parent 507d64e3e6
commit 843d9b0e1f
1 changed files with 2 additions and 2 deletions

4
ops.h
View File

@ -342,12 +342,12 @@ static HWY_NOINLINE HWY_MAYBE_UNUSED float SquaredL2(
const float* HWY_RESTRICT a, size_t size) {
const hn::ScalableTag<float> d;
const size_t N = hn::Lanes(d);
HWY_DASSERT(size >= N);
HWY_DASSERT(size >= 2 * N);
HWY_DASSERT(size % (2 * N) == 0);
auto sum0 = hn::Zero(d);
auto sum1 = hn::Zero(d);
for (size_t i = 0; i + 2 * N <= size; i += 2 * N) {
for (size_t i = 0; i <= size - 2 * N; i += 2 * N) {
const auto a0 = LoadU(d, a + i);
sum0 = MulAdd(a0, a0, sum0);
const auto a1 = LoadU(d, a + i + N);