Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Jan 3, 2025
1 parent f688ab4 commit 50848e0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/layer/reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ static int reduction_op(const Mat& a, Mat& b, bool reduce_w, bool reduce_h, bool
#pragma omp parallel for num_threads(opt.num_threads)
for (int i = 0; i < h; i++)
{
b[i] = reduction(v0, (const float*)mins, channels, mins.cstep, op2_type);
b[i] = reduction(v0, (const float*)mins + i, channels, mins.cstep, op2_type);
}
}

Expand Down Expand Up @@ -865,14 +865,17 @@ static int reduction_op(const Mat& a, Mat& b, bool reduce_w, bool reduce_h, bool
if (reduce_c) scale *= a.c;
}

const float coeff_mean = coeff / scale;
coeff = coeff / scale;
}

if (coeff != 1.f)
{
const int size = b.total();

#pragma omp parallel for num_threads(opt.num_threads)
for (int i = 0; i < size; i++)
{
b[i] = b[i] * coeff_mean;
b[i] = b[i] * coeff;
}
}

Expand Down

0 comments on commit 50848e0

Please sign in to comment.