Browse Source

fix code review comments

pull/8391/head
zhanghaibo5 5 years ago
parent
commit
8e611c0664
5 changed files with 26 additions and 12 deletions
  1. +7
    -6
      mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc
  2. +7
    -2
      mindspore/lite/src/runtime/kernel/arm/int8/add_int8.cc
  3. +6
    -1
      mindspore/lite/src/runtime/kernel/arm/int8/bias_add_int8.cc
  4. +5
    -2
      mindspore/lite/src/runtime/kernel/arm/int8/sub_int8.cc
  5. +1
    -1
      mindspore/lite/src/sub_graph_kernel.cc

+ 7
- 6
mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc View File

@@ -38,11 +38,11 @@ int CropBaseCPUKernel::ReSize() {
if (crop_para_->in_shape_ == nullptr) {
MS_LOG(ERROR) << "in_shape_ is nullptr";
return RET_ERROR;
} else {
memcpy(reinterpret_cast<void *>(const_cast<int *>(crop_para_->in_shape_)), input_shape.data(),
sizeof(int) * input_dim);
}

memcpy(reinterpret_cast<void *>(const_cast<int *>(crop_para_->in_shape_)), input_shape.data(),
sizeof(int) * input_dim);

auto *out_tensor = out_tensors_.at(kOutputIndex);
auto output_shape = out_tensor->shape();
size_t output_dim = output_shape.size();
@@ -51,10 +51,11 @@ int CropBaseCPUKernel::ReSize() {
if (crop_para_->out_shape_ == nullptr) {
MS_LOG(ERROR) << "out_shape_ is nullptr";
return RET_ERROR;
} else {
memcpy(reinterpret_cast<void *>(const_cast<int *>(crop_para_->out_shape_)), output_shape.data(),
sizeof(int) * output_dim);
}

memcpy(reinterpret_cast<void *>(const_cast<int *>(crop_para_->out_shape_)), output_shape.data(),
sizeof(int) * output_dim);

MS_ASSERT(input_dim <= CROP_OFFSET_MAX_SIZE);
crop_para_->input_dim_ = input_dim;
PadOffset(input_dim, crop_para_);


+ 7
- 2
mindspore/lite/src/runtime/kernel/arm/int8/add_int8.cc View File

@@ -101,9 +101,14 @@ int QuantizedAddCPUKernel::Run() {

if (in_tensors_.at(0)->ElementsNum() != in_tensors_.at(1)->ElementsNum()) {
input0_data_ = static_cast<int8_t *>(ctx_->allocator->Malloc(out_tensors_.at(0)->Size()));
if (input0_data_ == nullptr) {
MS_LOG(ERROR) << "malloc input0_data_ failed.";
return RET_ERROR;
}
input1_data_ = static_cast<int8_t *>(ctx_->allocator->Malloc(out_tensors_.at(0)->Size()));
if (!input0_data_ || !input1_data_) {
MS_LOG(ERROR) << "malloc input0_data_ || input1_data_ failed.";
if (input1_data_ == nullptr) {
MS_LOG(ERROR) << "malloc input1_data_ failed.";
ctx_->allocator->Free(input0_data_);
return RET_ERROR;
}



+ 6
- 1
mindspore/lite/src/runtime/kernel/arm/int8/bias_add_int8.cc View File

@@ -51,9 +51,14 @@ int BiasAddInt8CPUKernel::Run() {
auto out = reinterpret_cast<int8_t *>(out_tensors_.at(0)->MutableData());
size_t data_size = in_tensors_.at(0)->ElementsNum();
auto tile_in = static_cast<int8_t *>(ctx_->allocator->Malloc(data_size));
if (tile_in == nullptr) {
MS_LOG(ERROR) << "Failed to malloc momery";
return NNACL_ERR;
}
auto tile_bias = static_cast<int8_t *>(ctx_->allocator->Malloc(data_size));
if (tile_in == nullptr || tile_bias == nullptr) {
if (tile_bias == nullptr) {
MS_LOG(ERROR) << "Failed to malloc momery";
ctx_->allocator->Free(tile_in);
return NNACL_ERR;
}
BroadcastAddInt8(in, bias, tile_in, tile_bias, out, data_size,


+ 5
- 2
mindspore/lite/src/runtime/kernel/arm/int8/sub_int8.cc View File

@@ -132,11 +132,14 @@ int SubInt8CPUKernel::Run() {
tile_para.out_shape_[i] = out_tensors_.at(0)->DimensionSize(i);
}
tile0_data_ = static_cast<int8_t *>(context_->allocator->Malloc(out_tensors_.at(0)->Size()));
if (tile0_data_ == nullptr) {
MS_LOG(ERROR) << "malloc memroy fail!";
return RET_ERROR;
}
tile1_data_ = static_cast<int8_t *>(context_->allocator->Malloc(out_tensors_.at(0)->Size()));
if (tile0_data_ == nullptr || tile1_data_ == nullptr) {
if (tile1_data_ == nullptr) {
MS_LOG(ERROR) << "malloc memroy fail!";
context_->allocator->Free(tile0_data_);
context_->allocator->Free(tile1_data_);
return RET_ERROR;
}
TileDimensionsUint8(static_cast<uint8_t *>(in_tensors_.at(0)->MutableData()),


+ 1
- 1
mindspore/lite/src/sub_graph_kernel.cc View File

@@ -194,7 +194,7 @@ int CpuFp16SubGraph::PostProcess() {
tensor->set_data(nullptr);
tensor->set_data_type(TypeId::kNumberTypeFloat32);
auto ret = tensor->MallocData();
if (RET_OK != ret) {
if (ret != RET_OK) {
MS_LOG(ERROR) << "malloc data failed";
if (this->context_ != nullptr && this->context_->allocator != nullptr) {
this->context_->allocator->Free(float16_data);


Loading…
Cancel
Save