diff --git a/mindspore/lite/src/runtime/kernel/arm/base/gather_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/gather_base.cc index 2cc9b986b45..e11215c342c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/gather_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/gather_base.cc @@ -21,7 +21,7 @@ using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; namespace mindspore::kernel { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE constexpr int kMinCostPerThread = 16384; #endif int GatherRun(void *cdata, int task_id, float, float) { @@ -137,7 +137,7 @@ int GatherBaseCPUKernel::ChooseThreadCuttingstrategy() { return RET_OK; } int64_t block_size = 1; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE auto all_bytes = static_cast(out_tensors_.front()->Size()); if (all_bytes <= static_cast(kMinCostPerThread)) { block_boundary_infos_.emplace_back(BlockBoundaryInfo{0, 0, outer_size_, 0}); diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/bias_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/bias_fp32.cc index d4d7140436e..602634c08d9 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/bias_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/bias_fp32.cc @@ -28,7 +28,7 @@ using mindspore::lite::RET_OK; using mindspore::schema::PrimitiveType_BiasAdd; namespace mindspore::kernel { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE constexpr int kMinCostPerThread = 1 << 16; #endif int BiasAddRun(void *cdata, int task_id, float lhs_scale, float rhs_scale) { @@ -81,7 +81,7 @@ int BiasCPUKernel::ReSize() { int BiasCPUKernel::ChooseThreadCuttingstrategy() { split_points_.clear(); int64_t block_size = 1; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE block_size = MSMAX(total_num_ / op_parameter_->thread_num_, kMinCostPerThread); thread_num_ = MSMIN(UP_DIV(total_num_, block_size), op_parameter_->thread_num_); #else diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc index f4d3da39200..44c7edac75f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc @@ -74,7 +74,7 @@ int MatmulFp32BaseCPUKernel::PackMatrixA() { reinterpret_cast(ms_context_->allocator->Malloc(matrix_a_.pack_size * sizeof(float))); } } else { -#ifdef SERVER_INFERENCE +#ifdef SHARING_MODEL_WEIGHT auto a_packed = lite::PackWeightManager::GetInstance()->GetPackedTensor( in_tensors()[FIRST_INPUT], static_cast(matrix_a_.pack_size) * sizeof(float)); matrix_a_.pack_ptr = reinterpret_cast(a_packed.second); @@ -125,7 +125,7 @@ int MatmulFp32BaseCPUKernel::PackMatrixB() { reinterpret_cast(ms_context_->allocator->Malloc(matrix_b_.pack_size * sizeof(float))); } } else { -#ifdef SERVER_INFERENCE +#ifdef SHARING_MODEL_WEIGHT auto b_packed = lite::PackWeightManager::GetInstance()->GetPackedTensor( in_tensors()[SECOND_INPUT], static_cast(matrix_b_.pack_size) * sizeof(float)); matrix_b_.pack_ptr = reinterpret_cast(b_packed.second); diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.h b/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.h index bc77c79e107..15f50c11abf 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.h @@ -19,7 +19,7 @@ #include #include "src/inner_kernel.h" -#ifdef SERVER_INFERENCE +#ifdef SHARING_MODEL_WEIGHT #include "src/pack_weight_manager.h" #endif #include "nnacl/matmul_parameter.h" diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/div_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/div_int8.cc index 6e0c03a2078..3e14937fc62 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/div_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/div_int8.cc @@ -158,11 +158,28 @@ int DivInt8CPUKernel::Run() { if (broadcast_) { ArithmeticParameter tile_para; - tile_para.ndim_ = out_tensors_.at(0)->shape().size(); - for (size_t i = 0; i < tile_para.ndim_; i++) { - tile_para.in_shape0_[i] = in_tensors_.at(0)->DimensionSize(i); - tile_para.in_shape1_[i] = in_tensors_.at(1)->DimensionSize(i); - tile_para.out_shape_[i] = out_tensors_.at(0)->DimensionSize(i); + auto out_shape = out_tensors_[FIRST_INPUT]->shape(); + tile_para.ndim_ = out_shape.size(); + auto in_shape0 = in_tensors_[FIRST_INPUT]->shape(); + MS_CHECK_TRUE_MSG(out_shape.size() >= in_shape0.size(), RET_ERROR, + "Sub first-input shape size is larger than out."); + for (size_t i = 0; i < out_shape.size() - in_shape0.size(); ++i) { + tile_para.in_shape0_[i] = 1; + } + for (size_t i = 0; i < in_shape0.size(); ++i) { + tile_para.in_shape0_[i + out_shape.size() - in_shape0.size()] = in_shape0[i]; + } + auto in_shape1 = in_tensors_[SECOND_INPUT]->shape(); + MS_CHECK_TRUE_MSG(out_shape.size() >= in_shape1.size(), RET_ERROR, + "Sub second-input shape size is larger than out."); + for (size_t i = 0; i < out_shape.size() - in_shape1.size(); ++i) { + tile_para.in_shape1_[i] = 1; + } + for (size_t i = 0; i < in_shape1.size(); ++i) { + tile_para.in_shape1_[i + out_shape.size() - in_shape1.size()] = in_shape1[i]; + } + for (size_t i = 0; i < out_shape.size(); ++i) { + tile_para.out_shape_[i] = out_shape[i]; } tile0_data_ = static_cast(ms_context_->allocator->Malloc(out_tensors_.at(0)->Size())); tile1_data_ = static_cast(ms_context_->allocator->Malloc(out_tensors_.at(0)->Size()));