Skip to content

Commit

Permalink
v4.12.0 (microsoft#3)
Browse files Browse the repository at this point in the history
Co-authored-by: HailoRT-Automation <contact@hailo.ai>
  • Loading branch information
HailoRT-Automation and HailoRT-Automation authored Jan 8, 2023
1 parent cee693c commit 4635159
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ if (onnxruntime_USE_HAILO)
"${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.cc"
)

find_package(HailoRT 4.10.0 EXACT REQUIRED)
find_package(HailoRT 4.12.0 EXACT REQUIRED)

source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_hailo_cc_srcs})
onnxruntime_add_shared_library_module(onnxruntime_providers_hailo ${onnxruntime_providers_hailo_cc_srcs})
Expand Down
2 changes: 1 addition & 1 deletion hailo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Hailo ONNX Runtime integrates ONNX Runtime with HailoRT to enable Hailo-EP, prov
* ONNX Runtime version 1.11.1 with Python 3.7 and above

# Prerequisites
* HailoRT v4.10.0
* HailoRT v4.12.0

# Build Instructions
To build ONNXRuntime with HailoRT please follow the following steps:
Expand Down
12 changes: 12 additions & 0 deletions include/onnxruntime/core/session/onnxruntime_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -3303,6 +3303,18 @@ struct OrtApi {
*/
ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_MIGraphX,
_In_ OrtSessionOptions* options, _In_ const OrtMIGraphXProviderOptions* migraphx_options);


/** \brief Append Hailo execution provider to the session options
*
* If Hailo is not available (due to a non Hailo enabled build, or if HailoRT is not installed on the system), this function will fail.
*
* \param[in] options
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*/
ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_Hailo,
_In_ OrtSessionOptions* options, _In_ int use_arena); // TODO: HRT-8414
};

/*
Expand Down
1 change: 1 addition & 0 deletions include/onnxruntime/core/session/onnxruntime_cxx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ struct SessionOptions : Base<OrtSessionOptions> {
SessionOptions& AppendExecutionProvider_TensorRT(const OrtTensorRTProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT
SessionOptions& AppendExecutionProvider_TensorRT_V2(const OrtTensorRTProviderOptionsV2& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT
SessionOptions& AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_MIGraphX
SessionOptions& AppendExecutionProvider_Hailo(int use_arena); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_Hailo

SessionOptions& SetCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn); ///< Wraps OrtApi::SessionOptionsSetCustomCreateThreadFn
SessionOptions& SetCustomThreadCreationOptions(void* ort_custom_thread_creation_options); ///< Wraps OrtApi::SessionOptionsSetCustomThreadCreationOptions
Expand Down
5 changes: 5 additions & 0 deletions include/onnxruntime/core/session/onnxruntime_cxx_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ inline SessionOptions& SessionOptions::AppendExecutionProvider_OpenVINO(const Or
return *this;
}

inline SessionOptions& SessionOptions::AppendExecutionProvider_Hailo(int use_arena) {
ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_Hailo(p_, use_arena));
return *this;
}

inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options) {
ThrowOnError(GetApi().CreateSession(env, model_path, options, &p_));
}
Expand Down
2 changes: 2 additions & 0 deletions onnxruntime/core/session/onnxruntime_c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,8 @@ static constexpr OrtApi ort_api_1_to_11 = {
&OrtApis::ReleaseCUDAProviderOptions,
&OrtApis::SessionOptionsAppendExecutionProvider_MIGraphX,
// End of Version 11 - DO NOT MODIFY ABOVE (see above text for more information)

&OrtApis::SessionOptionsAppendExecutionProvider_Hailo,
};

// Asserts to do a some checks to ensure older Versions of the OrtApi never change (will detect an addition or deletion but not if they cancel out each other)
Expand Down
3 changes: 3 additions & 0 deletions onnxruntime/core/session/ort_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ ORT_API_STATUS_IMPL(SessionOptionsAppendExecutionProvider_OpenVINO,
_In_ OrtSessionOptions* options, _In_ const OrtOpenVINOProviderOptions* provider_options);
ORT_API_STATUS_IMPL(SetGlobalDenormalAsZero, _Inout_ OrtThreadingOptions* options);

ORT_API_STATUS_IMPL(SessionOptionsAppendExecutionProvider_Hailo,
_In_ OrtSessionOptions* options, int use_arena);

ORT_API_STATUS_IMPL(CreateArenaCfg, _In_ size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes,
int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out);
ORT_API(void, ReleaseArenaCfg, _Frees_ptr_opt_ OrtArenaCfg*);
Expand Down
8 changes: 6 additions & 2 deletions onnxruntime/core/session/provider_bridge_ort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1356,18 +1356,22 @@ ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_Dnnl, _In_ OrtSessi
API_IMPL_END
}

ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_Hailo, _In_ OrtSessionOptions* options, int use_arena) {
ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider_Hailo, _In_ OrtSessionOptions* options, int use_arena) {
API_IMPL_BEGIN
auto factory = onnxruntime::CreateExecutionProviderFactory_Hailo(use_arena);
if (!factory) {
return OrtApis::CreateStatus(ORT_FAIL, "OrtSessionOptionsAppendExecutionProvider_Hailo: Failed to load shared library");
return OrtApis::CreateStatus(ORT_FAIL, "SessionOptionsAppendExecutionProvider_Hailo: Failed to load shared library");
}

options->provider_factories.push_back(factory);
return nullptr;
API_IMPL_END
}

ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_Hailo, _In_ OrtSessionOptions* options, int use_arena) {
return OrtApis::SessionOptionsAppendExecutionProvider_Hailo(options, use_arena);
}

ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_Tensorrt, _In_ OrtSessionOptions* options, int device_id) {
API_IMPL_BEGIN
auto factory = onnxruntime::CreateExecutionProviderFactory_Tensorrt(device_id);
Expand Down
13 changes: 13 additions & 0 deletions onnxruntime/test/providers/hailo/hailo_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "core/graph/onnx_protobuf.h"
#include "core/graph/constants.h"
#include "core/session/inference_session.h"
#include "core/session/onnxruntime_c_api.h"
#include "core/session/onnxruntime_cxx_api.h"
#include "test/util/include/asserts.h"
#include "test/util/include/test_utils.h"
#include "test/util/include/default_providers.h"
Expand Down Expand Up @@ -290,6 +292,17 @@ TEST(HailoCustomOpTest, one_session_multiple_threads_stress)
}
}

TEST(HailoCustomOpTest, hailo_provider_in_ort_api)
{
const OrtApi* ort_api = OrtGetApiBase()->GetApi(11);
OrtSessionOptions* soptions;
auto so_status = ort_api->CreateSessionOptions(&soptions);
ASSERT_TRUE(so_status == nullptr); // nullptr for Status* indicates success (As written in onnxruntime_c_api.h)

auto provider_status = ort_api->SessionOptionsAppendExecutionProvider_Hailo(soptions, 1);
ASSERT_TRUE(provider_status == nullptr); // nullptr for Status* indicates success (As written in onnxruntime_c_api.h)
}

} // namespace test
} // namespace onnxruntime

2 changes: 1 addition & 1 deletion requirements.txt.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy >= @Python_NumPy_VERSION@
protobuf==3.15.6
protobuf==3.19.5
flatbuffers

0 comments on commit 4635159

Please sign in to comment.