diff --git a/onnxruntime/core/providers/vitisai/imp/global_api.cc b/onnxruntime/core/providers/vitisai/imp/global_api.cc index 8f4882bf9333a..772e778dd5ed4 100644 --- a/onnxruntime/core/providers/vitisai/imp/global_api.cc +++ b/onnxruntime/core/providers/vitisai/imp/global_api.cc @@ -54,6 +54,10 @@ struct OrtVitisAIEpAPI { int (*vitisai_ep_on_run_start)( const std::vector>& eps, const void* state, vaip_core::DllSafe (*get_config_entry)(const void* state, const char* entry_name)) = nullptr; + int (*vitisai_ep_set_ep_dynamic_options)( + const std::vector>& eps, + const char* const* keys, + const char* const* values, size_t kv_len) = nullptr; void Ensure() { if (handle_) return; @@ -79,6 +83,7 @@ struct OrtVitisAIEpAPI { (void**)&vaip_get_version); ORT_THROW_IF_ERROR(env.GetSymbolFromLibrary(handle_, "create_ep_context_nodes", (void**)&create_ep_context_nodes)); ORT_THROW_IF_ERROR(env.GetSymbolFromLibrary(handle_, "vitisai_ep_on_run_start", (void**)&vitisai_ep_on_run_start)); + ORT_THROW_IF_ERROR(env.GetSymbolFromLibrary(handle_, "vitisai_ep_set_ep_dynamic_options", (void**)&vitisai_ep_set_ep_dynamic_options)); } private: @@ -120,6 +125,15 @@ int vitisai_ep_on_run_start( return 100; } +int vitisai_ep_set_ep_dynamic_options( + const std::vector>& eps, const char* const* keys, + const char* const* values, size_t kv_len) { + if (s_library_vitisaiep.vitisai_ep_set_ep_dynamic_options) { + return s_library_vitisaiep.vitisai_ep_set_ep_dynamic_options(eps, keys, values, kv_len); + } + return 100; +} + struct MyCustomOpKernel : OpKernel { MyCustomOpKernel(const OpKernelInfo& info, const OrtCustomOp& op) : OpKernel(info), op_(op) { op_kernel_ = diff --git a/onnxruntime/core/providers/vitisai/include/vaip/global_api.h b/onnxruntime/core/providers/vitisai/include/vaip/global_api.h index 1a90f4c7fdebb..b0353bd6adae9 100644 --- a/onnxruntime/core/providers/vitisai/include/vaip/global_api.h +++ b/onnxruntime/core/providers/vitisai/include/vaip/global_api.h @@ -20,3 +20,7 @@ std::optional> create_ep_context_nodes( int vitisai_ep_on_run_start( const std::vector>& eps, const void* state, vaip_core::DllSafe (*get_config_entry)(const void* state, const char* entry_name)); +int vitisai_ep_set_ep_dynamic_options( + const std::vector>& eps, + const char* const* keys, + const char* const* values, size_t kv_len); diff --git a/onnxruntime/core/providers/vitisai/vitisai_execution_provider.cc b/onnxruntime/core/providers/vitisai/vitisai_execution_provider.cc index 09b115b4a57fc..633847e6f163b 100644 --- a/onnxruntime/core/providers/vitisai/vitisai_execution_provider.cc +++ b/onnxruntime/core/providers/vitisai/vitisai_execution_provider.cc @@ -110,9 +110,19 @@ common::Status VitisAIExecutionProvider::OnRunStart(const onnxruntime::RunOption }; auto error_code = vitisai_ep_on_run_start(**execution_providers_, (const void*)&run_options, get_config_entry); if (error_code) { - return Status(onnxruntime::common::ONNXRUNTIME, onnxruntime::common::StatusCode::FAIL, std::to_string(error_code)); + std::string error_msg = "vitisai_ep_on_run_start ret: " + std::to_string(error_code); + return Status(onnxruntime::common::ONNXRUNTIME, onnxruntime::common::StatusCode::FAIL, error_msg); } return Status::OK(); } +common::Status VitisAIExecutionProvider::SetEpDynamicOptions(gsl::span keys, + gsl::span values) { + auto error_code = vitisai_ep_set_ep_dynamic_options(**execution_providers_, keys.data(), values.data(), std::min(keys.size(), values.size())); + if (error_code) { + std::string error_msg = "vitisai_ep_set_ep_dynamic_options ret: " + std::to_string(error_code); + return Status(onnxruntime::common::ONNXRUNTIME, onnxruntime::common::StatusCode::FAIL, error_msg); + } + return Status::OK(); +} } // namespace onnxruntime diff --git a/onnxruntime/core/providers/vitisai/vitisai_execution_provider.h b/onnxruntime/core/providers/vitisai/vitisai_execution_provider.h index 05d2a976815b9..07085cd248d06 100644 --- a/onnxruntime/core/providers/vitisai/vitisai_execution_provider.h +++ b/onnxruntime/core/providers/vitisai/vitisai_execution_provider.h @@ -39,6 +39,8 @@ class VitisAIExecutionProvider : public IExecutionProvider { // This method is called after both `GetComputeCapabilityOps()` and `Compile()`. // This timing is required to work with both compliation-based EPs and non-compilation-based EPs. const InlinedVector GetEpContextNodes() const override; + virtual common::Status SetEpDynamicOptions(gsl::span /*keys*/, + gsl::span /*values*/) override; private: using my_ep_t = vaip_core::DllSafe>>;