diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 58d642da421..4a1783cbc31 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -152,7 +152,6 @@ if(MSLITE_ENABLE_SHARING_MODEL_WEIGHT) set(LITE_SRC ${LITE_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/pack_weight_manager.cc - ${CMAKE_CURRENT_SOURCE_DIR}/thread_cost_model.cc ) endif() diff --git a/mindspore/lite/src/inner_kernel.h b/mindspore/lite/src/inner_kernel.h index 0ece3fb5a19..c1b7eb0ae7c 100644 --- a/mindspore/lite/src/inner_kernel.h +++ b/mindspore/lite/src/inner_kernel.h @@ -32,7 +32,7 @@ #include "include/api/context.h" #include "include/api/kernel.h" -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE #include "src/thread_cost_model.h" #endif @@ -59,7 +59,7 @@ class InnerKernel : public Kernel { FreeWorkspace(); } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (thread_cost_context_ != nullptr) { free(thread_cost_context_); thread_cost_context_ = nullptr; @@ -207,7 +207,7 @@ class InnerKernel : public Kernel { const lite::Context *ms_context_ = nullptr; int thread_num_ = 1; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE lite::ThreadCostContext *thread_cost_context_ = nullptr; #endif }; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.cc index f0e0e213feb..cb3a33e83a6 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.cc @@ -25,7 +25,7 @@ using mindspore::lite::RET_OK; namespace mindspore::kernel { namespace { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE const std::map, float> arithmetic_compute_cost_map_ = { {{schema::PrimitiveType_MulFusion, schema::ActivationType_RELU}, 1.806f}, // dataNum about 100k {{schema::PrimitiveType_MulFusion, schema::ActivationType_RELU6}, 1.806f}, // dataNum about 100k @@ -332,7 +332,7 @@ void ArithmeticBaseCPUKernel::ComputeOfflineInfo() { int ArithmeticBaseCPUKernel::ChooseThreadCuttingstrategy() { auto total_num = out_tensors_.front()->ElementsNum(); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { return RET_ERROR; } @@ -449,7 +449,7 @@ void ArithmeticBaseCPUKernel::ComputeOffset(int task_id) { } } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int ArithmeticBaseCPUKernel::UpdateThreadNumPass() { std::pair fusion_type = std::make_pair(primitive_type_, param_->activation_type_); if (thread_cost_context_ == nullptr && arithmetic_compute_cost_map_.count(fusion_type) > 0) { diff --git a/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.h b/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.h index bbb4e1e59bd..c05d27e5ebe 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.h +++ b/mindspore/lite/src/runtime/kernel/arm/base/arithmetic_base.h @@ -89,7 +89,7 @@ class ArithmeticBaseCPUKernel : public InnerKernel { int BroadCastConstTensor(); void ComputeOfflineInfo(); int ChooseThreadCuttingstrategy(); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif void ComputeOffset(int task_id); diff --git a/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc index 9a3cd4cee0f..5fb5984a5c3 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc @@ -25,7 +25,7 @@ using mindspore::lite::RET_OK; using mindspore::schema::PrimitiveType_Split; namespace mindspore::kernel { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int SplitBaseCPUKernel::UpdateThreadNumPass() { if (thread_cost_context_ == nullptr && num_unit_ > 0) { thread_cost_context_ = new (std::nothrow) lite::ThreadCostContext(); @@ -122,7 +122,7 @@ int SplitBaseCPUKernel::ReSize() { MS_CHECK_FALSE(INT_MUL_OVERFLOW(param->split_count_, param->num_split_), RET_ERROR); num_unit_ = param->split_count_ * param->num_split_; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/base/split_base.h b/mindspore/lite/src/runtime/kernel/arm/base/split_base.h index b51b6eca12a..5fe4c843372 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/split_base.h +++ b/mindspore/lite/src/runtime/kernel/arm/base/split_base.h @@ -43,7 +43,7 @@ class SplitBaseCPUKernel : public InnerKernel { int Run() override; virtual int Split(int task_id); static int CheckAndInitSplitParam(const lite::Tensor &in_tensor, SplitParameter *param); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif diff --git a/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc index f1420191658..8b38ee096d7 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc @@ -54,7 +54,7 @@ static inline int GetOuterSize(const std::vector &in_shape, int axis) { return outer_size; } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int StackBaseCPUKernel::UpdateThreadNumPass() { if (thread_cost_context_ == nullptr) { thread_cost_context_ = new (std::nothrow) lite::ThreadCostContext(); @@ -88,7 +88,7 @@ int StackBaseCPUKernel::ReSize() { outer_size_ = GetOuterSize(input0_shape, axis_); } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/base/stack_base.h b/mindspore/lite/src/runtime/kernel/arm/base/stack_base.h index 070bebea0fc..3a6600babfc 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/stack_base.h +++ b/mindspore/lite/src/runtime/kernel/arm/base/stack_base.h @@ -35,7 +35,7 @@ class StackBaseCPUKernel : public InnerKernel { int ReSize() override; int Run() override; int StackExecute(int task_id); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif diff --git a/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.cc b/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.cc index c1ededad82b..8e345692526 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.cc @@ -64,7 +64,7 @@ void StridedSliceCPUKernel::InitFastRunParam() { outer_ == 1 ? (parallel_on_split_axis_ = true) : (parallel_on_outer_ = true); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { MS_LOG(ERROR) << "thread num update thread file."; return; @@ -75,7 +75,7 @@ void StridedSliceCPUKernel::InitFastRunParam() { parallel_on_split_axis_ ? UP_DIV(out_shape[split_axis_], thread_num_) : UP_DIV(outer_, thread_num_); } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int StridedSliceCPUKernel::UpdateThreadNumPass() { if (thread_cost_context_ == nullptr) { thread_cost_context_ = new (std::nothrow) lite::ThreadCostContext(); diff --git a/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.h b/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.h index 028c6801041..7f8101c03a1 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.h +++ b/mindspore/lite/src/runtime/kernel/arm/base/strided_slice.h @@ -39,7 +39,7 @@ class StridedSliceCPUKernel : public InnerKernel { int NormalRun(); int FastRun(); int FastRunImpl(int task_id); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc index 021df2d2289..0ea2685d30e 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc @@ -34,7 +34,7 @@ using mindspore::schema::PrimitiveType_Activation; namespace mindspore::kernel { namespace { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE const std::map activation_compute_cost_map_ = { {schema::ActivationType_RELU, 1.806f}, // dataNum about 100k {schema::ActivationType_RELU6, 1.806f}, // dataNum about 100k @@ -47,7 +47,7 @@ const std::map activation_compute_cost_map_ = { #endif } // namespace -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int ActivationCPUKernel::UpdateThreadNumPass() { if (thread_cost_context_ == nullptr && activation_compute_cost_map_.count(type_) > 0) { thread_cost_context_ = new (std::nothrow) lite::ThreadCostContext(); @@ -96,7 +96,7 @@ int ActivationCPUKernel::Prepare() { } int ActivationCPUKernel::ReSize() { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.h index f2ea0edeecd..148aac8914b 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.h @@ -36,7 +36,7 @@ class ActivationCPUKernel : public InnerKernel { } ~ActivationCPUKernel() override = default; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc index 5059669b782..b4f503cf72d 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc @@ -28,7 +28,7 @@ struct TYPE_FUNC_INFO { ArithmeticSelfFunc func_ = nullptr; }; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE const std::map arithmetic_self_compute_cost_map_ = { // {schema::PrimitiveType_Abs, 0.5f}, // {schema::PrimitiveType_Cos, 1.0f}, @@ -48,7 +48,7 @@ const std::map arithmetic_self_compute_cost_map_ = { #endif } // namespace -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int ArithmeticSelfCPUKernel::UpdateThreadNumPass() { if (thread_cost_context_ == nullptr && arithmetic_self_compute_cost_map_.count(type_) > 0) { thread_cost_context_ = new (std::nothrow) lite::ThreadCostContext(); @@ -108,7 +108,7 @@ int ArithmeticSelfCPUKernel::Prepare() { } int ArithmeticSelfCPUKernel::ReSize() { -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.h index 9c77543e653..74241318261 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.h @@ -49,7 +49,7 @@ class ArithmeticSelfCPUKernel : public InnerKernel { } ~ArithmeticSelfCPUKernel() override = default; -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif int Prepare() override; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.cc index 3da9347c6d6..17fb06ffa87 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.cc @@ -43,7 +43,7 @@ int SoftmaxCPUKernel::Prepare() { return ReSize(); } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int SoftmaxCPUKernel::UpdateThreadNumPass() { if (thread_cost_context_ == nullptr) { thread_cost_context_ = new (std::nothrow) lite::ThreadCostContext(); @@ -91,7 +91,7 @@ int SoftmaxCPUKernel::ReSize() { } } -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE if (UpdateThreadNumPass() != RET_OK) { return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.h index adbaf537e97..18e46b9aafc 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/softmax_fp32.h @@ -37,7 +37,7 @@ class SoftmaxCPUKernel : public SoftmaxBaseCPUKernel { int ReSize() override; int Run() override; int DoSoftmaxLastAxis(int task_id); -#ifdef SERVER_INFERENCE +#ifdef DYNAMIC_THREAD_DISTRIBUTE int UpdateThreadNumPass(); #endif