forked from mindspore-Ecosystem/mindspore
!23532 [MSLITE] enable mindrt off
Merge pull request !23532 from ling/bug
This commit is contained in:
commit
58c9053d9d
|
@ -211,18 +211,13 @@ endif()
|
|||
|
||||
if(MSLITE_ENABLE_MINDRT)
|
||||
add_subdirectory(${CORE_DIR}/mindrt mindspore_mindrt)
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
set(LITE_SRC ${LITE_SRC}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lite_mindrt.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mindrt_executor.cc
|
||||
)
|
||||
else()
|
||||
file(GLOB MINDRT_ACTOR ${CORE_DIR}/mindrt/src/actor/*.cc)
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
${MINDRT_ACTOR}
|
||||
set(LITE_SRC ${LITE_SRC}
|
||||
${CORE_DIR}/mindrt/src/thread/core_affinity.cc
|
||||
${CORE_DIR}/mindrt/src/thread/actor_threadpool.cc
|
||||
${CORE_DIR}/mindrt/src/thread/threadpool.cc
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include "include/errorcode.h"
|
||||
#include "src/common/log_adapter.h"
|
||||
#include "src/common/log_util.h"
|
||||
#ifdef ENABLE_MINDRT
|
||||
#include "thread/actor_threadpool.h"
|
||||
#endif
|
||||
#ifdef SUPPORT_NPU
|
||||
#include "include/HiAiModelManagerType.h"
|
||||
#endif
|
||||
|
@ -27,7 +30,9 @@
|
|||
|
||||
namespace mindspore::lite {
|
||||
namespace {
|
||||
#ifdef ENABLE_MINDRT
|
||||
constexpr int kDefaultParallelNum = 2;
|
||||
#endif
|
||||
const constexpr int kMaxLiteContextDeviceNums = 2;
|
||||
const constexpr int kMaxInnerContextDeviceNums = 3;
|
||||
} // namespace
|
||||
|
@ -110,12 +115,13 @@ int InnerContext::Init() {
|
|||
return RET_NOT_SUPPORT;
|
||||
}
|
||||
if (this->thread_pool_ == nullptr) {
|
||||
int actor_parallel_thread = this->enable_parallel_ ? kDefaultParallelNum : 1;
|
||||
BindMode bind_mode = Power_NoBind;
|
||||
if (this->IsCpuEnabled()) {
|
||||
bind_mode = static_cast<BindMode>(this->GetCpuDeviceInfo()->cpu_bind_mode_);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MINDRT
|
||||
int actor_parallel_thread = this->enable_parallel_ ? kDefaultParallelNum : 1;
|
||||
if (this->affinity_core_list_.empty()) {
|
||||
thread_pool_ = ActorThreadPool::CreateThreadPool(actor_parallel_thread, this->thread_num_, bind_mode);
|
||||
if (thread_pool_ == nullptr) {
|
||||
|
@ -130,6 +136,10 @@ int InnerContext::Init() {
|
|||
return RET_NULL_PTR;
|
||||
}
|
||||
}
|
||||
#else
|
||||
thread_pool_ = ThreadPool::CreateThreadPool(thread_num_);
|
||||
thread_pool_->SetCpuAffinity(static_cast<mindspore::BindMode>(bind_mode));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (this->allocator == nullptr) {
|
||||
|
@ -344,12 +354,12 @@ NpuDeviceInfo InnerContext::GetNpuInfo() const {
|
|||
}
|
||||
}
|
||||
|
||||
ActorThreadPool *InnerContext::thread_pool() const { return thread_pool_; }
|
||||
ThreadPool *InnerContext::thread_pool() const { return thread_pool_; }
|
||||
|
||||
bool InnerContext::device_and_pkg_support_fp16() const { return this->device_and_pkg_support_fp16_; }
|
||||
|
||||
int ParallelLaunch(const Context *context, const Func &func, Content content, int task_num) {
|
||||
ActorThreadPool *pool = static_cast<const lite::InnerContext *>(context)->thread_pool();
|
||||
ThreadPool *pool = static_cast<const lite::InnerContext *>(context)->thread_pool();
|
||||
if (pool == nullptr) {
|
||||
MS_LOG(ERROR) << "thread pool is nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <string>
|
||||
#include "include/context.h"
|
||||
#include "src/runtime/inner_allocator.h"
|
||||
#include "thread/actor_threadpool.h"
|
||||
#include "thread/threadpool.h"
|
||||
#ifdef ENABLE_ARM
|
||||
#include "src/cpu_info.h"
|
||||
#endif
|
||||
|
@ -58,7 +58,7 @@ struct InnerContext : public Context {
|
|||
|
||||
int IsValid() const;
|
||||
|
||||
ActorThreadPool *thread_pool() const;
|
||||
ThreadPool *thread_pool() const;
|
||||
|
||||
virtual ~InnerContext();
|
||||
|
||||
|
@ -81,7 +81,7 @@ struct InnerContext : public Context {
|
|||
|
||||
bool device_and_pkg_support_fp16_ = false;
|
||||
|
||||
ActorThreadPool *thread_pool_{nullptr};
|
||||
ThreadPool *thread_pool_{nullptr};
|
||||
};
|
||||
|
||||
int ParallelLaunch(const Context *context, const Func &func, Content content, int task_num);
|
||||
|
|
|
@ -784,7 +784,7 @@ std::vector<std::shared_ptr<LiteOpActor>> CreateOpActor(const std::vector<kernel
|
|||
const lite::InnerContext *ctx) {
|
||||
std::vector<std::shared_ptr<LiteOpActor>> actors;
|
||||
std::unordered_map<kernel::LiteKernel *, AID> subgraph_name_AID_map{};
|
||||
auto thread_pool = ctx->thread_pool();
|
||||
ActorThreadPool *thread_pool = reinterpret_cast<ActorThreadPool *>(ctx->thread_pool());
|
||||
if (thread_pool == nullptr) {
|
||||
MS_LOG(ERROR) << "thread pool is nullptr";
|
||||
return actors;
|
||||
|
|
|
@ -977,7 +977,7 @@ int LiteSession::Resize(const std::vector<mindspore::tensor::MSTensor *> &inputs
|
|||
int LiteSession::InitGPURuntime() {
|
||||
if (context_->IsCpuEnabled()) {
|
||||
CpuBindMode cpu_bind_mode = context_->GetCpuDeviceInfo()->cpu_bind_mode_;
|
||||
ActorThreadPool *thread_pool = this->context_->thread_pool();
|
||||
ThreadPool *thread_pool = this->context_->thread_pool();
|
||||
if (thread_pool == nullptr) {
|
||||
MS_LOG(ERROR) << "thread pool is nullptr";
|
||||
is_running_.store(false);
|
||||
|
@ -1011,7 +1011,7 @@ int LiteSession::InitGPURuntime() {
|
|||
#endif
|
||||
// Setting the binding core will affect the opencl drive scheduling.
|
||||
if (context_->IsCpuEnabled()) {
|
||||
ActorThreadPool *thread_pool = this->context_->thread_pool();
|
||||
ThreadPool *thread_pool = this->context_->thread_pool();
|
||||
thread_pool->SetProcessAffinity(static_cast<BindMode>(NO_BIND));
|
||||
}
|
||||
return RET_OK;
|
||||
|
|
Loading…
Reference in New Issue