Browse Source

fix reduce for loop size bug

tags/v0.7.0-beta
zhaozhenlong 5 years ago
parent
commit
aa6be43437
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      mindspore/lite/src/runtime/kernel/arm/fp32/reduce.cc

+ 5
- 5
mindspore/lite/src/runtime/kernel/arm/fp32/reduce.cc View File

@@ -70,13 +70,13 @@ int ReduceCPUKernel::CheckParameters() {
return RET_ERROR; return RET_ERROR;
} }
for (auto i = 0; i < num_axes_; i++) { for (auto i = 0; i < num_axes_; i++) {
if (static_cast<size_t>(axes_[i]) < -input_rank || static_cast<size_t>(axes_[i]) >= input_rank) {
MS_LOG(ERROR) << "Reduce got invalid axis " << axes_[i] << ", axis should be in [" << -input_rank << ", "
<< input_rank - 1 << "].";
if (axes_[i] < -static_cast<int>(input_rank) || static_cast<size_t>(axes_[i]) >= input_rank) {
MS_LOG(ERROR) << "Reduce got invalid axis " << axes_[i] << ", axis should be in ["
<< -static_cast<int>(input_rank) << ", " << input_rank - 1 << "].";
return RET_ERROR; return RET_ERROR;
} }
if (axes_[i] < 0) { if (axes_[i] < 0) {
axes_[i] += input_rank;
axes_[i] += static_cast<int>(input_rank);
} }
} }


@@ -154,7 +154,7 @@ int ReduceImpl(int task_id, LiteParallelGroupEnv *penv, void *cdata) {
int ReduceCPUKernel::Run() { int ReduceCPUKernel::Run() {
tmp_shape_ = inputs_.at(0)->shape(); tmp_shape_ = inputs_.at(0)->shape();
src_data_ = static_cast<float *>(inputs_.at(0)->Data()); src_data_ = static_cast<float *>(inputs_.at(0)->Data());
for (int i = 0; i < tmp_shape_.size(); ++i) {
for (int i = 0; i < data_buffers_.size(); ++i) {
dst_data_ = data_buffers_[i]; dst_data_ = data_buffers_[i];
int axis = axes_[i]; int axis = axes_[i];
outer_size_ = 1; outer_size_ = 1;


Loading…
Cancel
Save