143 lines
7.0 KiB
Diff
143 lines
7.0 KiB
Diff
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
|
|
index acbde7f56a8..eb9f7bb9fbf 100644
|
|
--- a/cmake/CMakeLists.txt
|
|
+++ b/cmake/CMakeLists.txt
|
|
@@ -718,7 +718,7 @@ if (onnxruntime_BUILD_BENCHMARKS)
|
|
endif()
|
|
endif()
|
|
|
|
-if (NOT WIN32 AND NOT onnxruntime_PREFER_SYSTEM_LIB)
|
|
+if (NOT WIN32)
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/external/nsync EXCLUDE_FROM_ALL)
|
|
endif()
|
|
# External dependencies
|
|
diff --git a/include/onnxruntime/core/platform/ort_mutex.h b/include/onnxruntime/core/platform/ort_mutex.h
|
|
index e24665f5142..ddc11953fbc 100644
|
|
--- a/include/onnxruntime/core/platform/ort_mutex.h
|
|
+++ b/include/onnxruntime/core/platform/ort_mutex.h
|
|
@@ -101,7 +101,7 @@ std::cv_status OrtCondVar::wait_for(std::unique_lock<OrtMutex>& cond_mutex,
|
|
return steady_clock::now() - steady_now < rel_time ? std::cv_status::no_timeout : std::cv_status::timeout;
|
|
}
|
|
} // namespace onnxruntime
|
|
-#else
|
|
+#elif !defined(__aarch64__)
|
|
#include "nsync.h"
|
|
#include <mutex> //for unique_lock
|
|
#include <condition_variable> //for cv_status
|
|
@@ -186,4 +186,11 @@ std::cv_status OrtCondVar::wait_for(std::unique_lock<OrtMutex>& cond_mutex,
|
|
return steady_clock::now() - steady_now < rel_time ? std::cv_status::no_timeout : std::cv_status::timeout;
|
|
}
|
|
}; // namespace onnxruntime
|
|
+#else
|
|
+#include <mutex>
|
|
+#include <condition_variable>
|
|
+namespace onnxruntime {
|
|
+using OrtMutex = std::mutex;
|
|
+using OrtCondVar = std::condition_variable;
|
|
+} // namespace onnxruntime
|
|
#endif
|
|
diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h
|
|
index 048421099bd..4430185d496 100644
|
|
--- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h
|
|
+++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h
|
|
@@ -379,9 +379,9 @@ struct ModelMetadata : Base<OrtModelMetadata> {
|
|
*/
|
|
struct Session : Base<OrtSession> {
|
|
explicit Session(std::nullptr_t) {} ///< Create an empty Session object, must be assigned a valid one to be used
|
|
- Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options); ///< Wraps OrtApi::CreateSession
|
|
- Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options, OrtPrepackedWeightsContainer* prepacked_weights_container); ///< Wraps OrtApi::CreateSessionWithPrepackedWeightsContainer
|
|
- Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options); ///< Wraps OrtApi::CreateSessionFromArray
|
|
+ Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options); ///< Wraps OrtApi::CreateSession
|
|
+ Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options, OrtPrepackedWeightsContainer* prepacked_weights_container); ///< Wraps OrtApi::CreateSessionWithPrepackedWeightsContainer
|
|
+ Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options); ///< Wraps OrtApi::CreateSessionFromArray
|
|
|
|
/** \brief Run the model returning results in an Ort allocated vector.
|
|
*
|
|
diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h
|
|
index 1f31dffca87..b9d2cdfc475 100644
|
|
--- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h
|
|
+++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h
|
|
@@ -538,16 +538,16 @@ inline SessionOptions& SessionOptions::AppendExecutionProvider_OpenVINO(const Or
|
|
return *this;
|
|
}
|
|
|
|
-inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options) {
|
|
+inline Session::Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options) {
|
|
ThrowOnError(GetApi().CreateSession(env, model_path, options, &p_));
|
|
}
|
|
|
|
-inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
|
|
+inline Session::Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
|
|
OrtPrepackedWeightsContainer* prepacked_weights_container) {
|
|
ThrowOnError(GetApi().CreateSessionWithPrepackedWeightsContainer(env, model_path, options, prepacked_weights_container, &p_));
|
|
}
|
|
|
|
-inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) {
|
|
+inline Session::Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) {
|
|
ThrowOnError(GetApi().CreateSessionFromArray(env, model_data, model_data_length, options, &p_));
|
|
}
|
|
|
|
diff --git a/onnxruntime/core/mlas/lib/platform.cpp b/onnxruntime/core/mlas/lib/platform.cpp
|
|
index de7fee8c07a..6d97cf07a05 100644
|
|
--- a/onnxruntime/core/mlas/lib/platform.cpp
|
|
+++ b/onnxruntime/core/mlas/lib/platform.cpp
|
|
@@ -16,6 +16,7 @@ Module Name:
|
|
--*/
|
|
|
|
#include "mlasi.h"
|
|
+#include <string>
|
|
|
|
#if defined(MLAS_TARGET_POWER) && defined(__linux__)
|
|
#include <sys/auxv.h>
|
|
@@ -197,8 +198,11 @@ Return Value:
|
|
//
|
|
|
|
uint64_t xcr0 = MlasReadExtendedControlRegister(_XCR_XFEATURE_ENABLED_MASK);
|
|
+ const char *cpu_opt = std::getenv("MLAS_DYNAMIC_CPU_ARCH");
|
|
+ if (cpu_opt == nullptr) cpu_opt = "99";
|
|
+ auto opt = std::stoi(cpu_opt);
|
|
|
|
- if ((xcr0 & 0x6) == 0x6) {
|
|
+ if (opt > 0 && (xcr0 & 0x6) == 0x6) {
|
|
|
|
this->GemmFloatKernel = MlasGemmFloatKernelAvx;
|
|
|
|
@@ -231,7 +235,7 @@ Return Value:
|
|
__cpuid_count(7, 0, Cpuid7[0], Cpuid7[1], Cpuid7[2], Cpuid7[3]);
|
|
#endif
|
|
|
|
- if (((Cpuid1[2] & 0x1000) != 0) && ((Cpuid7[1] & 0x20) != 0)) {
|
|
+ if (opt > 1 && ((Cpuid1[2] & 0x1000) != 0) && ((Cpuid7[1] & 0x20) != 0)) {
|
|
|
|
this->GemmU8S8Dispatch = &MlasGemmU8S8DispatchAvx2;
|
|
this->GemmU8S8Kernel = MlasGemmU8S8KernelAvx2;
|
|
@@ -290,7 +294,7 @@ Return Value:
|
|
// operating system supports saving AVX512F state.
|
|
//
|
|
|
|
- if (((Cpuid7[1] & 0x10000) != 0) && ((xcr0 & 0xE0) == 0xE0)) {
|
|
+ if (opt > 2 && ((Cpuid7[1] & 0x10000) != 0) && ((xcr0 & 0xE0) == 0xE0)) {
|
|
|
|
this->GemmFloatKernel = MlasGemmFloatKernelAvx512F;
|
|
this->GemmDoubleKernel = MlasGemmDoubleKernelAvx512F;
|
|
diff --git a/onnxruntime/core/platform/posix/ort_mutex.cc b/onnxruntime/core/platform/posix/ort_mutex.cc
|
|
index 8a5d41eb360..89111c9daa5 100644
|
|
--- a/onnxruntime/core/platform/posix/ort_mutex.cc
|
|
+++ b/onnxruntime/core/platform/posix/ort_mutex.cc
|
|
@@ -1,6 +1,7 @@
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
+#if !defined(__aarch64__)
|
|
#include "core/common/common.h"
|
|
#include "core/platform/ort_mutex.h"
|
|
#include <assert.h>
|
|
@@ -40,4 +41,5 @@ void OrtCondVar::wait(std::unique_lock<OrtMutex>& lk) {
|
|
nsync::nsync_cv_wait(&native_cv_object, lk.mutex()->native_handle());
|
|
}
|
|
|
|
-} // namespace onnxruntime
|
|
\ No newline at end of file
|
|
+} // namespace onnxruntime
|
|
+#endif
|