2424#ifdef LITE_WITH_XPU
2525#include < functional>
2626#include < mutex> // NOLINT
27+ #include " lite/backends/xpu/runtime_option.h"
2728#include " lite/backends/xpu/target_wrapper.h"
2829#endif
2930
@@ -264,6 +265,11 @@ ConfigBase::ConfigBase(PowerMode mode, int threads) {
264265 mode_ = lite::DeviceInfo::Global ().mode ();
265266 threads_ = lite::DeviceInfo::Global ().threads ();
266267#endif
268+ #ifdef LITE_WITH_XPU
269+ std::shared_ptr<void > runtime_option =
270+ std::shared_ptr<lite::XPURunTimeOption>(new lite::XPURunTimeOption);
271+ target_configs_.emplace (TARGET (kXPU ), std::move (runtime_option));
272+ #endif
267273}
268274
269275void ConfigBase::set_opencl_binary_path_name (const std::string &path,
@@ -483,10 +489,14 @@ void CxxConfig::set_xpu_l3_cache_method(size_t l3_size, bool locked) {
483489 CHECK (lite::TargetWrapperXPU::shared_l3_size >= l3_size)
484490 << " Enlarge XPU Shared L3 Cache Is Not Allowed." ;
485491 }
486- lite::TargetWrapperXPU::local_l3_size = 0 ;
492+ reinterpret_cast <lite::XPURunTimeOption *>(
493+ target_configs ()[TARGET (kXPU )].get ())
494+ ->xpu_local_l3_size = 0 ;
487495 lite::TargetWrapperXPU::need_l3_mutex = true ;
488496 } else {
489- lite::TargetWrapperXPU::local_l3_size = l3_size;
497+ reinterpret_cast <lite::XPURunTimeOption *>(
498+ target_configs ()[TARGET (kXPU )].get ())
499+ ->xpu_local_l3_size = l3_size;
490500 lite::TargetWrapperXPU::need_l3_mutex = false ;
491501 }
492502#else
@@ -498,17 +508,21 @@ void CxxConfig::set_xpu_l3_cache_method(size_t l3_size, bool locked) {
498508
499509void CxxConfig::set_xpu_l3_cache_autotune (bool autotune) {
500510#ifdef LITE_WITH_XPU
501- lite::TargetWrapperXPU::local_l3_autotune = autotune;
511+ reinterpret_cast <lite::XPURunTimeOption *>(
512+ target_configs ()[TARGET (kXPU )].get ())
513+ ->xpu_local_l3_autotune = autotune;
502514#else
503515 LOG (WARNING) << " The invoking of the function "
504516 " 'set_xpu_l3_cache_autotune' is ignored, please "
505517 " rebuild it with LITE_WITH_XPU=ON." ;
506518#endif
507519}
508520
509- void set_xpu_gm_workspace_method (size_t gm_size) {
521+ void CxxConfig:: set_xpu_gm_workspace_method (size_t gm_size) {
510522#ifdef LITE_WITH_XPU
511- lite::TargetWrapperXPU::local_gm_size = gm_size;
523+ reinterpret_cast <lite::XPURunTimeOption *>(
524+ target_configs ()[TARGET (kXPU )].get ())
525+ ->xpu_local_gm_size = gm_size;
512526#else
513527 LOG (WARNING) << " The invoking of the function "
514528 " 'set_xpu_gm_workspace_method' is ignored, please "
@@ -518,7 +532,9 @@ void set_xpu_gm_workspace_method(size_t gm_size) {
518532
519533void CxxConfig::set_xpu_dev_per_thread (int dev_no) {
520534#ifdef LITE_WITH_XPU
521- lite::TargetWrapperXPU::SetDev (dev_no);
535+ reinterpret_cast <lite::XPURunTimeOption *>(
536+ target_configs ()[TARGET (kXPU )].get ())
537+ ->xpu_dev_num = dev_no;
522538#else
523539 LOG (WARNING) << " The invoking of the function 'set_xpu_dev_per_thread' is "
524540 " ignored, please rebuild it with LITE_WITH_XPU=ON." ;
@@ -527,7 +543,9 @@ void CxxConfig::set_xpu_dev_per_thread(int dev_no) {
527543
528544void CxxConfig::enable_xpu_multi_stream () {
529545#ifdef LITE_WITH_XPU
530- lite::TargetWrapperXPU::enable_xpu_multi_stream ();
546+ reinterpret_cast <lite::XPURunTimeOption *>(
547+ target_configs ()[TARGET (kXPU )].get ())
548+ ->xpu_enable_multi_stream = true ;
531549#else
532550 LOG (WARNING)
533551 << " The invoking of the function 'enable_xpu_stream_per_thread' is "
@@ -596,7 +614,9 @@ void CxxConfig::set_xpu_conv_autotune(bool autotune,
596614
597615void CxxConfig::set_xpu_cluster_num (const int num) {
598616#ifdef LITE_WITH_XPU
599- lite::TargetWrapperXPU::cluster_num = num;
617+ reinterpret_cast <lite::XPURunTimeOption *>(
618+ target_configs ()[TARGET (kXPU )].get ())
619+ ->xpu_cluster_num = num;
600620#else
601621 LOG (WARNING) << " The invoking of the function "
602622 " 'set_xpu_cluster_num' is ignored, please "
@@ -606,14 +626,40 @@ void CxxConfig::set_xpu_cluster_num(const int num) {
606626
607627void CxxConfig::set_xpu_sdnn_num (const int num) {
608628#ifdef LITE_WITH_XPU
609- lite::TargetWrapperXPU::sdnn_num = num;
629+ reinterpret_cast <lite::XPURunTimeOption *>(
630+ target_configs ()[TARGET (kXPU )].get ())
631+ ->xpu_sdnn_num = num;
610632#else
611633 LOG (WARNING) << " The invoking of the function "
612634 " 'set_xpu_sdnn_num' is ignored, please "
613635 " rebuild it with LITE_WITH_XPU=ON." ;
614636#endif
615637}
616638
639+ void CxxConfig::set_xpu_dump_tensor_path (const std::string dump_tensor_path) {
640+ #ifdef LITE_WITH_XPU
641+ reinterpret_cast <lite::XPURunTimeOption *>(
642+ target_configs ()[TARGET (kXPU )].get ())
643+ ->xpu_dump_tensor_path = dump_tensor_path;
644+ #else
645+ LOG (WARNING) << " The invoking of the function "
646+ " 'set_xpu_dump_tensor_path' is ignored, please "
647+ " rebuild it with LITE_WITH_XPU=ON." ;
648+ #endif
649+ }
650+
651+ void CxxConfig::set_xpu_dump_log_path (const std::string dump_log_path) {
652+ #ifdef LITE_WITH_XPU
653+ reinterpret_cast <lite::XPURunTimeOption *>(
654+ target_configs ()[TARGET (kXPU )].get ())
655+ ->xpu_dump_log_path = dump_log_path;
656+ #else
657+ LOG (WARNING) << " The invoking of the function "
658+ " 'set_xpu_dump_log_path' is ignored, please "
659+ " rebuild it with LITE_WITH_XPU=ON." ;
660+ #endif
661+ }
662+
617663template <class T >
618664void CxxConfig::set_preferred_inputs_for_warmup (const int group_idx,
619665 const int tensor_idx,
0 commit comments