mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
bdf348c13a
Added MLAS third party module and integrated into GeMM path #28934 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
31 lines
1019 B
C++
31 lines
1019 B
C++
// Shim for ORT's core/common/narrow.h — used by the vendored MLAS (cast.cpp).
|
|
// Upstream provides a checked narrowing cast a la gsl::narrow. The MLAS
|
|
// translation units here only #include the header; they do not actually
|
|
// invoke narrow<T>(...). We provide a minimal definition anyway so the file
|
|
// compiles cleanly and any future MLAS update that does call narrow keeps
|
|
// working.
|
|
//
|
|
// This file is intentionally tiny so OpenCV can keep a stable shim while
|
|
// upstream MLAS evolves.
|
|
|
|
#pragma once
|
|
|
|
#include <stdexcept>
|
|
#include <type_traits>
|
|
|
|
namespace onnxruntime {
|
|
|
|
template <typename T, typename U>
|
|
constexpr T narrow(U u) {
|
|
static_assert(std::is_arithmetic<T>::value && std::is_arithmetic<U>::value,
|
|
"narrow<T>(U): T and U must be arithmetic types");
|
|
const T t = static_cast<T>(u);
|
|
if (static_cast<U>(t) != u ||
|
|
((t < T{}) != (u < U{}))) {
|
|
throw std::runtime_error("onnxruntime::narrow: narrowing failed");
|
|
}
|
|
return t;
|
|
}
|
|
|
|
} // namespace onnxruntime
|