mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-23 22:13:38 +00:00
[VitisAI] update version and api & bug fix (#20851)
### Description <!-- Describe your changes. --> 1. Use macro defined to check version number 2. Add a new api 3. Fix bug at attr_proto ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> These are some problems we need to address for the final delivery to Microsoft.
This commit is contained in:
parent
25ac65375c
commit
59b13b7bbd
6 changed files with 19 additions and 6 deletions
|
|
@ -370,6 +370,7 @@ struct ProviderHost {
|
|||
virtual void AttributeProto__set_s(ONNX_NAMESPACE::AttributeProto* p, const ::std::string& value) = 0;
|
||||
virtual void AttributeProto__set_f(ONNX_NAMESPACE::AttributeProto* p, const float& value) = 0;
|
||||
virtual void AttributeProto__set_i(ONNX_NAMESPACE::AttributeProto* p, int64_t value) = 0;
|
||||
virtual void AttributeProto__set_t(ONNX_NAMESPACE::AttributeProto* p, const ONNX_NAMESPACE::TensorProto& tensor) = 0;
|
||||
virtual const ::std::string& AttributeProto__s(const ONNX_NAMESPACE::AttributeProto* p) = 0;
|
||||
virtual void AttributeProto__set_name(ONNX_NAMESPACE::AttributeProto* p, const ::std::string& value) = 0;
|
||||
virtual void AttributeProto__set_type(ONNX_NAMESPACE::AttributeProto* p, ONNX_NAMESPACE::AttributeProto_AttributeType value) = 0;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ struct AttributeProto final {
|
|||
void set_s(const ::std::string& value) { return g_host->AttributeProto__set_s(this, value); }
|
||||
void set_f(const float& value) { return g_host->AttributeProto__set_f(this, value); }
|
||||
void set_i(int64_t value) { return g_host->AttributeProto__set_i(this, value); }
|
||||
void set_t(const TensorProto& value) { return g_host->AttributeProto__set_t(this, value); }
|
||||
const ::std::string& s() const { return g_host->AttributeProto__s(this); }
|
||||
void set_name(const ::std::string& value) { return g_host->AttributeProto__set_name(this, value); }
|
||||
void set_type(AttributeProto_AttributeType value) { return g_host->AttributeProto__set_type(this, value); }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ ONNX_NAMESPACE::AttributeProto* attr_proto_new_tensor(
|
|||
auto ret = ONNX_NAMESPACE::AttributeProto::Create();
|
||||
ret->set_name(name);
|
||||
ret->set_type(ONNX_NAMESPACE::AttributeProto_AttributeType_TENSOR);
|
||||
*ret->add_tensors() = value;
|
||||
ret->set_t(value);
|
||||
return ret.release();
|
||||
}
|
||||
ONNX_NAMESPACE::AttributeProto* attr_proto_new_ints(const std::string& name, const std::vector<int64_t>& value) {
|
||||
|
|
|
|||
|
|
@ -183,9 +183,9 @@ void initialize_vitisai_ep() {
|
|||
static void set_version_info(vaip_core::OrtApiForVaip& api) {
|
||||
const char* magic = "VAIP";
|
||||
std::memcpy(reinterpret_cast<char*>(&api.magic), magic, sizeof(api.magic));
|
||||
api.major = 1u;
|
||||
api.minor = 0u;
|
||||
api.patch = 0u;
|
||||
api.major = VAIP_ORT_API_MAJOR;
|
||||
api.minor = VAIP_ORT_API_MINOR;
|
||||
api.patch = VAIP_ORT_API_PATCH;
|
||||
}
|
||||
|
||||
vaip_core::OrtApiForVaip* create_org_api_hook() {
|
||||
|
|
@ -371,6 +371,11 @@ vaip_core::OrtApiForVaip* create_org_api_hook() {
|
|||
the_global_api.get_lib_id = []() -> vaip_core::DllSafe<std::string> {
|
||||
return vaip_core::DllSafe(std::string(GIT_COMMIT_ID));
|
||||
};
|
||||
|
||||
the_global_api.graph_add_initialized_tensor = [](Graph& graph, const ONNX_NAMESPACE::TensorProto& tensor) {
|
||||
graph.AddInitializedTensor(tensor);
|
||||
};
|
||||
|
||||
if (!s_library_vitisaiep.vaip_get_version) {
|
||||
return reinterpret_cast<vaip_core::OrtApiForVaip*>(&(the_global_api.host_));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ struct OrtApi;
|
|||
|
||||
namespace vaip_core {
|
||||
|
||||
#define VAIP_ORT_API_MAJOR (2u)
|
||||
#define VAIP_ORT_API_MINOR (0u)
|
||||
#define VAIP_ORT_API_PATCH (0u)
|
||||
struct OrtApiForVaip {
|
||||
uint32_t magic; // 'VAIP' or something else to make sure the following field
|
||||
// are not garbage.
|
||||
|
|
@ -191,8 +194,10 @@ struct OrtApiForVaip {
|
|||
gsl::span<const char> (*tensor_proto_as_raw)(
|
||||
const TensorProto& tensor); // [79]
|
||||
|
||||
DllSafe<std::string> (*get_lib_id)(); // [80]
|
||||
DllSafe<std::string> (*get_lib_name)(); // [81]
|
||||
DllSafe<std::string> (*get_lib_id)(); // [80]
|
||||
DllSafe<std::string> (*get_lib_name)(); // [81]
|
||||
/** new API after 2.0 */
|
||||
void (*graph_add_initialized_tensor)(Graph& graph, const TensorProto& tensor); // [82]
|
||||
};
|
||||
|
||||
#ifndef USE_VITISAI
|
||||
|
|
|
|||
|
|
@ -472,6 +472,7 @@ struct ProviderHostImpl : ProviderHost {
|
|||
void AttributeProto__set_s(ONNX_NAMESPACE::AttributeProto* p, const ::std::string& value) override { return p->set_s(value); }
|
||||
void AttributeProto__set_f(ONNX_NAMESPACE::AttributeProto* p, const float& value) override { return p->set_f(value); }
|
||||
void AttributeProto__set_i(ONNX_NAMESPACE::AttributeProto* p, int64_t value) override { return p->set_i(value); }
|
||||
void AttributeProto__set_t(ONNX_NAMESPACE::AttributeProto* p, const ONNX_NAMESPACE::TensorProto& value) override { *p->mutable_t() = value; }
|
||||
const ::std::string& AttributeProto__s(const ONNX_NAMESPACE::AttributeProto* p) override { return p->s(); }
|
||||
void AttributeProto__set_name(ONNX_NAMESPACE::AttributeProto* p, const ::std::string& value) override { return p->set_name(value); }
|
||||
void AttributeProto__set_type(ONNX_NAMESPACE::AttributeProto* p, ONNX_NAMESPACE::AttributeProto_AttributeType value) override { return p->set_type(value); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue