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
@@ -266,6 +267,11 @@ ConfigBase::ConfigBase(PowerMode mode, int threads) {
266267 mode_ = lite::DeviceInfo::Global ().mode ();
267268 threads_ = lite::DeviceInfo::Global ().threads ();
268269#endif
270+ #ifdef LITE_WITH_XPU
271+ std::shared_ptr<void > runtime_option =
272+ std::shared_ptr<lite::XPURunTimeOption>(new lite::XPURunTimeOption);
273+ runtime_options_.emplace (TARGET (kXPU ), std::move (runtime_option));
274+ #endif
269275}
270276
271277void ConfigBase::set_opencl_binary_path_name (const std::string &path,
@@ -478,10 +484,14 @@ void CxxConfig::set_xpu_l3_cache_method(size_t l3_size, bool locked) {
478484 CHECK (lite::TargetWrapperXPU::shared_l3_size >= l3_size)
479485 << " Enlarge XPU Shared L3 Cache Is Not Allowed." ;
480486 }
481- lite::TargetWrapperXPU::local_l3_size = 0 ;
487+ reinterpret_cast <lite::XPURunTimeOption *>(
488+ runtime_options ()[TARGET (kXPU )].get ())
489+ ->xpu_local_l3_size = 0 ;
482490 lite::TargetWrapperXPU::need_l3_mutex = true ;
483491 } else {
484- lite::TargetWrapperXPU::local_l3_size = l3_size;
492+ reinterpret_cast <lite::XPURunTimeOption *>(
493+ runtime_options ()[TARGET (kXPU )].get ())
494+ ->xpu_local_l3_size = l3_size;
485495 lite::TargetWrapperXPU::need_l3_mutex = false ;
486496 }
487497#else
@@ -493,17 +503,21 @@ void CxxConfig::set_xpu_l3_cache_method(size_t l3_size, bool locked) {
493503
494504void CxxConfig::set_xpu_l3_cache_autotune (bool autotune) {
495505#ifdef LITE_WITH_XPU
496- lite::TargetWrapperXPU::local_l3_autotune = autotune;
506+ reinterpret_cast <lite::XPURunTimeOption *>(
507+ runtime_options ()[TARGET (kXPU )].get ())
508+ ->xpu_local_l3_autotune = autotune;
497509#else
498510 LOG (WARNING) << " The invoking of the function "
499511 " 'set_xpu_l3_cache_autotune' is ignored, please "
500512 " rebuild it with LITE_WITH_XPU=ON." ;
501513#endif
502514}
503515
504- void set_xpu_gm_workspace_method (size_t gm_size) {
516+ void CxxConfig:: set_xpu_gm_workspace_method (size_t gm_size) {
505517#ifdef LITE_WITH_XPU
506- lite::TargetWrapperXPU::local_gm_size = gm_size;
518+ reinterpret_cast <lite::XPURunTimeOption *>(
519+ runtime_options ()[TARGET (kXPU )].get ())
520+ ->xpu_local_gm_size = gm_size;
507521#else
508522 LOG (WARNING) << " The invoking of the function "
509523 " 'set_xpu_gm_workspace_method' is ignored, please "
@@ -513,7 +527,9 @@ void set_xpu_gm_workspace_method(size_t gm_size) {
513527
514528void CxxConfig::set_xpu_dev_per_thread (int dev_no) {
515529#ifdef LITE_WITH_XPU
516- lite::TargetWrapperXPU::SetDev (dev_no);
530+ reinterpret_cast <lite::XPURunTimeOption *>(
531+ runtime_options ()[TARGET (kXPU )].get ())
532+ ->xpu_dev_num = dev_no;
517533#else
518534 LOG (WARNING) << " The invoking of the function 'set_xpu_dev_per_thread' is "
519535 " ignored, please rebuild it with LITE_WITH_XPU=ON." ;
@@ -522,7 +538,9 @@ void CxxConfig::set_xpu_dev_per_thread(int dev_no) {
522538
523539void CxxConfig::enable_xpu_multi_stream () {
524540#ifdef LITE_WITH_XPU
525- lite::TargetWrapperXPU::enable_xpu_multi_stream ();
541+ reinterpret_cast <lite::XPURunTimeOption *>(
542+ runtime_options ()[TARGET (kXPU )].get ())
543+ ->xpu_enable_multi_stream = true ;
526544#else
527545 LOG (WARNING)
528546 << " The invoking of the function 'enable_xpu_stream_per_thread' is "
@@ -591,7 +609,9 @@ void CxxConfig::set_xpu_conv_autotune(bool autotune,
591609
592610void CxxConfig::set_xpu_cluster_num (const int num) {
593611#ifdef LITE_WITH_XPU
594- lite::TargetWrapperXPU::cluster_num = num;
612+ reinterpret_cast <lite::XPURunTimeOption *>(
613+ runtime_options ()[TARGET (kXPU )].get ())
614+ ->xpu_cluster_num = num;
595615#else
596616 LOG (WARNING) << " The invoking of the function "
597617 " 'set_xpu_cluster_num' is ignored, please "
@@ -601,14 +621,40 @@ void CxxConfig::set_xpu_cluster_num(const int num) {
601621
602622void CxxConfig::set_xpu_sdnn_num (const int num) {
603623#ifdef LITE_WITH_XPU
604- lite::TargetWrapperXPU::sdnn_num = num;
624+ reinterpret_cast <lite::XPURunTimeOption *>(
625+ runtime_options ()[TARGET (kXPU )].get ())
626+ ->xpu_sdnn_num = num;
605627#else
606628 LOG (WARNING) << " The invoking of the function "
607629 " 'set_xpu_sdnn_num' is ignored, please "
608630 " rebuild it with LITE_WITH_XPU=ON." ;
609631#endif
610632}
611633
634+ void CxxConfig::set_xpu_dump_tensor_path (const std::string dump_tensor_path) {
635+ #ifdef LITE_WITH_XPU
636+ reinterpret_cast <lite::XPURunTimeOption *>(
637+ runtime_options ()[TARGET (kXPU )].get ())
638+ ->xpu_dump_tensor_path = dump_tensor_path;
639+ #else
640+ LOG (WARNING) << " The invoking of the function "
641+ " 'set_xpu_dump_tensor_path' is ignored, please "
642+ " rebuild it with LITE_WITH_XPU=ON." ;
643+ #endif
644+ }
645+
646+ void CxxConfig::set_xpu_dump_log_path (const std::string dump_log_path) {
647+ #ifdef LITE_WITH_XPU
648+ reinterpret_cast <lite::XPURunTimeOption *>(
649+ runtime_options ()[TARGET (kXPU )].get ())
650+ ->xpu_dump_log_path = dump_log_path;
651+ #else
652+ LOG (WARNING) << " The invoking of the function "
653+ " 'set_xpu_dump_log_path' is ignored, please "
654+ " rebuild it with LITE_WITH_XPU=ON." ;
655+ #endif
656+ }
657+
612658template <class T >
613659void CxxConfig::set_preferred_inputs_for_warmup (const int group_idx,
614660 const int tensor_idx,
0 commit comments