Skip to content

Commit

Permalink
add profiling api for vitis ai ep
Browse files Browse the repository at this point in the history
  • Loading branch information
Yueqing Zhang committed Nov 13, 2024
1 parent 69a36eb commit 30c2167
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ struct ProviderHost {
virtual const ConfigOptions& RunOptions__GetConfigOptions(const RunOptions* p) = 0;
// OrtSessionOptions
virtual const std::unordered_map<std::string, std::string>& SessionOptions__GetConfigOptionsMap(const OrtSessionOptions* p) = 0;
virtual bool SessionOptions__GetEnableProfiling(const OrtSessionOptions* p) = 0;
// ComputeCapability
virtual std::unique_ptr<ComputeCapability> ComputeCapability__construct(std::unique_ptr<IndexedSubGraph> t_sub_graph) = 0;
virtual void ComputeCapability__operator_delete(ComputeCapability* p) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1466,5 +1466,8 @@ struct OrtSessionOptions final {
const std::unordered_map<std::string, std::string>& GetConfigOptions() const {
return onnxruntime::g_host->SessionOptions__GetConfigOptionsMap(this);
}
bool GetEnableProfiling() const {
return onnxruntime::g_host->SessionOptions__GetEnableProfiling(this);
}
PROVIDER_DISALLOW_ALL(OrtSessionOptions)
};
4 changes: 4 additions & 0 deletions onnxruntime/core/providers/vitisai/imp/global_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ vaip_core::OrtApiForVaip* create_org_api_hook() {
return vaip_core::DllSafe(model_proto.SerializeAsString());
};
the_global_api.model_proto_delete = [](ONNX_NAMESPACE::ModelProto* p) { delete p; };
the_global_api.is_profiling_enabled = [](void* session_options) {
auto options = reinterpret_cast<OrtSessionOptions*>(session_options);
return options->GetEnableProfiling();
};
if (!s_library_vitisaiep.vaip_get_version) {
return reinterpret_cast<vaip_core::OrtApiForVaip*>(&(the_global_api.host_));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct OrtApi;

namespace vaip_core {

#define VAIP_ORT_API_MAJOR (11u)
#define VAIP_ORT_API_MAJOR (12u)
#define VAIP_ORT_API_MINOR (0u)
#define VAIP_ORT_API_PATCH (0u)
struct OrtApiForVaip {
Expand Down Expand Up @@ -234,6 +234,7 @@ struct OrtApiForVaip {
ModelProto* (*model_to_proto)(Model& model); // [95]
DllSafe<std::string> (*model_proto_serialize_as_string)(ModelProto& model_proto); // [96]
void (*model_proto_delete)(ModelProto* p); // [97]
bool (*is_profiling_enabled)(void* session_options); // [98]
};

#ifndef USE_VITISAI
Expand Down
1 change: 1 addition & 0 deletions onnxruntime/core/session/provider_bridge_ort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ struct ProviderHostImpl : ProviderHost {

// OrtSessionOptions (wrapped)
const std::unordered_map<std::string, std::string>& SessionOptions__GetConfigOptionsMap(const OrtSessionOptions* p) override { return p->value.config_options.configurations; }
bool SessionOptions__GetEnableProfiling(const OrtSessionOptions* p) override { return p->value.enable_profiling; };
// ComputeCapability (wrapped)
std::unique_ptr<ComputeCapability> ComputeCapability__construct(std::unique_ptr<IndexedSubGraph> t_sub_graph) override { return std::make_unique<ComputeCapability>(std::move(t_sub_graph)); }
void ComputeCapability__operator_delete(ComputeCapability* p) override { delete p; }
Expand Down

0 comments on commit 30c2167

Please sign in to comment.