提交 63d439ec 编写于 作者: xiebaiyuan's avatar xiebaiyuan

move "temp = numel / (dim[0] * dim[1]);" out to improve prelu performance

上级 42aafdfb
...@@ -33,8 +33,6 @@ struct PReluFunctor { ...@@ -33,8 +33,6 @@ struct PReluFunctor {
* */ * */
template <> template <>
void PReluKernel<CPU, float>::Compute(const PReluParam &param) const { void PReluKernel<CPU, float>::Compute(const PReluParam &param) const {
DLOG << "PReluKernel :Compute";
auto *x = param.InputX(); auto *x = param.InputX();
auto *alpha = param.InputAlpha(); auto *alpha = param.InputAlpha();
auto *out = param.Out(); auto *out = param.Out();
...@@ -48,9 +46,9 @@ void PReluKernel<CPU, float>::Compute(const PReluParam &param) const { ...@@ -48,9 +46,9 @@ void PReluKernel<CPU, float>::Compute(const PReluParam &param) const {
int i = 0; int i = 0;
int temp = 0; int temp = 0;
if (mode == "channel") { if (mode == "channel") {
temp = numel / (dim[0] * dim[1]);
#pragma omp parallel for #pragma omp parallel for
for (i = 0; i < numel; i++) { for (i = 0; i < numel; i++) {
temp = numel / (dim[0] * dim[1]);
index = (i / temp) % dim[1]; index = (i / temp) % dim[1];
o_ptr[i] = x_ptr[i] > 0 ? x_ptr[i] : alpha_ptr[index] * x_ptr[i]; o_ptr[i] = x_ptr[i] > 0 ? x_ptr[i] : alpha_ptr[index] * x_ptr[i];
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册