mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-07 00:13:17 +00:00
[VitisAI] Vitis ai ep support dynamic options (#22386)
### Description relate to #22282. Let Vitis ai ep handles dynamic_options ### Motivation and Context --------- Co-authored-by: genmingz <genmingz@amd.com>
This commit is contained in:
parent
88676e62b9
commit
34a61e2df4
4 changed files with 31 additions and 1 deletions
|
|
@ -54,6 +54,10 @@ struct OrtVitisAIEpAPI {
|
|||
int (*vitisai_ep_on_run_start)(
|
||||
const std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>& eps, const void* state,
|
||||
vaip_core::DllSafe<std::string> (*get_config_entry)(const void* state, const char* entry_name)) = nullptr;
|
||||
int (*vitisai_ep_set_ep_dynamic_options)(
|
||||
const std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>& 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<std::unique_ptr<vaip_core::ExecutionProvider>>& 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_ =
|
||||
|
|
|
|||
|
|
@ -20,3 +20,7 @@ std::optional<std::vector<onnxruntime::Node*>> create_ep_context_nodes(
|
|||
int vitisai_ep_on_run_start(
|
||||
const std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>& eps, const void* state,
|
||||
vaip_core::DllSafe<std::string> (*get_config_entry)(const void* state, const char* entry_name));
|
||||
int vitisai_ep_set_ep_dynamic_options(
|
||||
const std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>& eps,
|
||||
const char* const* keys,
|
||||
const char* const* values, size_t kv_len);
|
||||
|
|
|
|||
|
|
@ -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<const char* const> keys,
|
||||
gsl::span<const char* const> 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
|
||||
|
|
|
|||
|
|
@ -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<const Node*> GetEpContextNodes() const override;
|
||||
virtual common::Status SetEpDynamicOptions(gsl::span<const char* const> /*keys*/,
|
||||
gsl::span<const char* const> /*values*/) override;
|
||||
|
||||
private:
|
||||
using my_ep_t = vaip_core::DllSafe<std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue