From 934e359fcf4297a096520957f627edd3085241b2 Mon Sep 17 00:00:00 2001 From: zhaodezan Date: Fri, 14 Aug 2020 09:41:56 -0400 Subject: [PATCH] fix caffe prelu --- mindspore/lite/src/runtime/kernel/arm/fp32/caffeprelu.cc | 2 +- mindspore/lite/src/runtime/kernel/arm/nnacl/caffeprelu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/caffeprelu.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/caffeprelu.cc index e8cecd3e74f..15be6963469 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/caffeprelu.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/caffeprelu.cc @@ -59,7 +59,7 @@ int CaffePReluCPUKernel::Run() { output_data = reinterpret_cast(out_tensors_[0]->Data()); auto channels = input->shape(); prelu_param_->negtive_slope_ = reinterpret_cast(input1->Data()); - prelu_param_->channel_num_ = channels.at(channels.size() - 1); + prelu_param_->channel_num_ = channels.at(1); auto ret = LiteBackendParallelLaunch(CaffePReluRun, this, prelu_param_->op_parameter_.thread_num_); if (ret != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/nnacl/caffeprelu.c b/mindspore/lite/src/runtime/kernel/arm/nnacl/caffeprelu.c index 4eb5943eecd..eb05521c42a 100644 --- a/mindspore/lite/src/runtime/kernel/arm/nnacl/caffeprelu.c +++ b/mindspore/lite/src/runtime/kernel/arm/nnacl/caffeprelu.c @@ -27,7 +27,7 @@ void CaffePRelu(float *input, float *output, CaffePReluParameter *prelu_param_, output[i] = input[i]; } else { if (!prelu_param_->channeShared) { - int temp = i % prelu_param_->channel_num_; + int temp = i / (prelu_param_->input_num_ / prelu_param_->channel_num_); output[i] = input[i] * prelu_param_->negtive_slope_[temp]; } else { output[i] = input[i] * prelu_param_->negtive_slope_[0];