Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attrProto.release_s interface #22977

Merged
merged 11 commits into from
Dec 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ struct ProviderHost {
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;
virtual ONNX_NAMESPACE::TensorProto* AttributeProto__add_tensors(ONNX_NAMESPACE::AttributeProto* p) = 0;
virtual std::string* AttributeProto__release_s(ONNX_NAMESPACE::AttributeProto* p) = 0;

// GraphProto
virtual std::unique_ptr<ONNX_NAMESPACE::GraphProto> GraphProto__construct() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct AttributeProto final {
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); }
TensorProto* add_tensors() { return g_host->AttributeProto__add_tensors(this); }
std::string* release_s() { return g_host->AttributeProto__release_s(this); }

typedef AttributeProto_AttributeType AttributeType;
static constexpr AttributeType UNDEFINED = AttributeProto_AttributeType_UNDEFINED;
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/core/providers/vitisai/imp/attr_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,8 @@ std::vector<std::string> attr_proto_get_strings(const ONNX_NAMESPACE::AttributeP
}
return ret;
}
std::string* attr_proto_release_string(ONNX_NAMESPACE::AttributeProto* attr) {
vai_assert(attr->type() == ONNX_NAMESPACE::AttributeProto_AttributeType_STRING, attr->name());
return attr->release_s();
}
} // namespace vaip
1 change: 1 addition & 0 deletions onnxruntime/core/providers/vitisai/imp/attr_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
gsl::span<const int64_t> attr_proto_get_ints(const ONNX_NAMESPACE::AttributeProto& attr);
gsl::span<const float> attr_proto_get_floats(const ONNX_NAMESPACE::AttributeProto& attr);
std::vector<std::string> attr_proto_get_strings(const ONNX_NAMESPACE::AttributeProto& attr);
std::string* attr_proto_release_string(ONNX_NAMESPACE::AttributeProto* attr);

Check warning on line 26 in onnxruntime/core/providers/vitisai/imp/attr_proto.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/imp/attr_proto.h:26: Add #include <string> for string [build/include_what_you_use] [4]

} // namespace vaip
7 changes: 7 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,13 @@
return vaip_core::DllSafe(model_proto.SerializeAsString());
};
the_global_api.model_proto_delete = [](ONNX_NAMESPACE::ModelProto* p) { delete p; };
the_global_api.attr_proto_release_string = [](ONNX_NAMESPACE::AttributeProto* attr) -> vaip_core::DllSafe<std::string> {
auto pstr = vaip::attr_proto_release_string(attr);
std::string local_str = std::move(*pstr);
pstr = nullptr;
return vaip_core::DllSafe<std::string>(std::move(local_str));

Check warning on line 456 in onnxruntime/core/providers/vitisai/imp/global_api.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Add #include <utility> for move [build/include_what_you_use] [4] Raw Output: onnxruntime/core/providers/vitisai/imp/global_api.cc:456: Add #include <utility> for move [build/include_what_you_use] [4]

Check warning on line 456 in onnxruntime/core/providers/vitisai/imp/global_api.cc

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/imp/global_api.cc:456: Add #include <string> for string [build/include_what_you_use] [4]
};

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 @@

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 @@
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]
DllSafe<std::string> (*attr_proto_release_string)(AttributeProto* attr); // [98]

Check warning on line 237 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:237: Add #include <string> for string [build/include_what_you_use] [4]
};

#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 @@ -496,6 +496,7 @@ struct ProviderHostImpl : ProviderHost {
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); }
ONNX_NAMESPACE::TensorProto* AttributeProto__add_tensors(ONNX_NAMESPACE::AttributeProto* p) override { return p->add_tensors(); }
std::string* AttributeProto__release_s(ONNX_NAMESPACE::AttributeProto* p) override { return p->release_s(); }

// GraphProto (wrapped)
std::unique_ptr<ONNX_NAMESPACE::GraphProto> GraphProto__construct() override { return std::make_unique<ONNX_NAMESPACE::GraphProto>(); }
Expand Down
Loading