Browse Source

!12921 [MSLITE][Develop] reduce arithmetic memory

From: @sunsuodong
Reviewed-by: @zhang_xue_tong,@zhanghaibo5
Signed-off-by: @zhang_xue_tong
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
e19dc16eff
4 changed files with 13 additions and 6 deletions
  1. +0
    -1
      mindspore/lite/nnacl/fp32/conv_common_fp32.c
  2. +10
    -0
      mindspore/lite/src/runtime/kernel/arm/fp16/cast_fp16.cc
  3. +2
    -4
      mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_fp32.cc
  4. +1
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/batch_to_space_fp32.h

+ 0
- 1
mindspore/lite/nnacl/fp32/conv_common_fp32.c View File

@@ -16,7 +16,6 @@

#include "nnacl/fp32/conv_common_fp32.h"
#include <string.h>
#include "nnacl/fp32/common_func_fp32.h"
#include "nnacl/fp32/matmul_fp32.h"

// fp32 conv common


+ 10
- 0
mindspore/lite/src/runtime/kernel/arm/fp16/cast_fp16.cc View File

@@ -111,6 +111,16 @@ int CastFp16CPUKernel::DoCast(int thread_id) {
MS_LOG(ERROR) << "Unsupported output data type " << output_data_type;
return RET_ERROR;
}
} else if (input_data_type == kNumberTypeInt32) {
switch (output_data_type) {
case kNumberTypeFloat32:
Int32ToFloat32(static_cast<int32_t *>(input->data_c()) + offset, static_cast<float *>(output_data) + offset,
data_num);
break;
default:
MS_LOG(ERROR) << "Unsupported output data type " << output_data_type;
return RET_ERROR;
}
} else {
MS_LOG(ERROR) << "Unsupported input data type " << input_data_type;
return RET_ERROR;


+ 2
- 4
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_fp32.cc View File

@@ -91,8 +91,7 @@ int ArithmeticCPUKernel::ConstTensorBroadCast() {
param_->in_elements_num1_ != param_->out_elements_num_) {
return RET_OK;
}
if ((param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) &&
(arithmetic_opt_run_ != nullptr && arithmetic_opt_run_int_ != nullptr)) {
if ((param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) && arithmetic_opt_run_ != nullptr) {
/* run opt function
* one of input is scalar */
return RET_OK;
@@ -327,8 +326,7 @@ int ArithmeticCPUKernel::DoArithmetic(int task_id) {
}
int offset = stride * task_id * data_type_len_;
/* run opt function, one of input is scalar */
if ((param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) &&
(arithmetic_opt_run_ != nullptr && arithmetic_opt_run_int_ != nullptr)) {
if ((param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) && arithmetic_opt_run_ != nullptr) {
if (param_->in_elements_num0_ == 1) {
return Execute(input0_ptr_, static_cast<uint8_t *>(input1_ptr_) + offset,
static_cast<uint8_t *>(output_ptr_) + offset, count, true);


+ 1
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/batch_to_space_fp32.h View File

@@ -38,7 +38,7 @@ class BatchToSpaceCPUKernel : public LiteKernel {
private:
int32_t block_shape_[BATCH_TO_SPACE_BLOCK_SHAPE_SIZE];
int32_t crops_[COMM_SHAPE_SIZE];
bool no_crop_;
bool no_crop_ = false;
};
} // namespace mindspore::kernel



Loading…
Cancel
Save