Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions onnxruntime/core/providers/vitisai/imp/global_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ vaip_core::OrtApiForVaip* create_org_api_hook() {
graph.RemoveInitializedTensor(tensor_name);
};
the_global_api.graph_reverse_dfs_from_preemp = vaip::graph_reverse_dfs_from;
the_global_api.graph_save_string = vaip::graph_save_string;

if (!s_library_vitisaiep.vaip_get_version) {
return reinterpret_cast<vaip_core::OrtApiForVaip*>(&(the_global_api.host_));
} else {
Expand Down
23 changes: 23 additions & 0 deletions onnxruntime/core/providers/vitisai/imp/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,29 @@ void graph_save(const Graph& graph, const std::string& filename, const std::stri
vai_assert(result, "model serialize to ostream error");
}

vaip_core::DllSafe<std::string> graph_save_string(const Graph& graph) {
auto model_proto = const_cast<onnxruntime::Model&>(graph.GetModel()).ToProto();
auto graph_proto_subgraph = graph.ToGraphProto();
*model_proto->mutable_graph() = *graph_proto_subgraph;
auto& logger = logging::LoggingManager::DefaultLogger();
auto model = Model::Create(std::move(*model_proto), graph.ModelPath(), nullptr, logger);
model_proto = model->ToProto();
auto& metadata = model->MetaData();
if (!metadata.empty()) {
auto metadata_props = model_proto->mutable_metadata_props();
metadata_props->Clear();
for (auto& m : metadata) {
auto prop = metadata_props->Add();
*prop->mutable_key() = m.first;
*prop->mutable_value() = m.second;
}
}
std::string graph_string;
bool result = model_proto->SerializeToString(graph_string);
vai_assert(result, "model serialize to string error");
return vaip_core::DllSafe(graph_string);
}

Node& graph_fuse(Graph& graph, const std::string& name,
const std::string& op_type,
const std::vector<size_t>& nodes,
Expand Down
1 change: 1 addition & 0 deletions onnxruntime/core/providers/vitisai/include/vaip/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Node& graph_add_node(Graph& graph, const std::string& name, const std::string& o
const NodeAttributes& attributes, const std::string& domain);
void graph_save(const Graph& graph, const std::string& filename, const std::string& dat_filename,
size_t initializer_size_threshold);
vaip_core::DllSafe<std::string> graph_save_string(const Graph& graph);
Node& graph_fuse(Graph& graph, const std::string& name, const std::string& op_type, const std::vector<size_t>& nodes,
const std::vector<std::string>& inputs, const std::vector<std::string>& outputs,
const std::vector<std::string>& constant_initializers);
Expand Down
11 changes: 6 additions & 5 deletions onnxruntime/core/providers/vitisai/include/vaip/vaip_ort_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace vaip_core {

#define VAIP_ORT_API_MAJOR (17u)
#define VAIP_ORT_API_MAJOR (18u)
#define VAIP_ORT_API_MINOR (0u)
#define VAIP_ORT_API_PATCH (0u)
struct OrtApiForVaip {
Expand Down Expand Up @@ -252,10 +252,11 @@
stop); // [103]
void (*graph_set_name)(Graph& graph, const char* name); // [104]
void (*graph_infer_shapes_from_filepath)(
const std::string& m, const std::string& save_path); // [105]
GraphProto* (*graph_to_graph_proto)(const Graph& graph); // [106]
void (*graph_proto_delete)(GraphProto* p); // [107]
void (*graph_infer_shapes)(ModelProto& m); // [108]
const std::string& m, const std::string& save_path); // [105]
GraphProto* (*graph_to_graph_proto)(const Graph& graph); // [106]
void (*graph_proto_delete)(GraphProto* p); // [107]
void (*graph_infer_shapes)(ModelProto& m); // [108]
DllSafe<std::string> (*graph_save_string)(const Graph& graph); // [109]

Check warning on line 259 in onnxruntime/core/providers/vitisai/include/vaip/vaip_ort_api.h

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Add #include <string> for string [build/include_what_you_use] [4] Raw Output: onnxruntime/core/providers/vitisai/include/vaip/vaip_ort_api.h:259: Add #include <string> for string [build/include_what_you_use] [4]
};

#ifndef USE_VITISAI
Expand Down
Loading