mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +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
44 lines
1.8 KiB
C++
44 lines
1.8 KiB
C++
// Shim for ORT's core/common/common.h. Provides the small subset of
|
|
// macros that MLAS's q4_dq.cpp / q4common.h use: ORT_ENFORCE and ORT_THROW.
|
|
// Upstream's common.h pulls in logging, status, exceptions, and lots more
|
|
// — none of which MLAS itself needs. We map both macros to throwing
|
|
// std::runtime_error since MLAS is built without exception-disable in
|
|
// our CMake (see mlasi.h's MLAS_NO_EXCEPTION guard).
|
|
|
|
#pragma once
|
|
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace onnxruntime {
|
|
|
|
// Concatenate stream-like arguments into a single string. Supports the
|
|
// same `operator<<` chain that ORT_ENFORCE uses for its diagnostic.
|
|
template <typename... Args>
|
|
inline std::string MlasShimMakeMessage(const Args&... args) {
|
|
std::ostringstream oss;
|
|
using expand = int[];
|
|
(void)expand{0, ((void)(oss << args), 0)...};
|
|
return oss.str();
|
|
}
|
|
|
|
} // namespace onnxruntime
|
|
|
|
#define ORT_THROW(...) \
|
|
do { \
|
|
throw std::runtime_error( \
|
|
::onnxruntime::MlasShimMakeMessage(__VA_ARGS__)); \
|
|
} while (0)
|
|
|
|
#define ORT_ENFORCE(cond, ...) \
|
|
do { \
|
|
if (!(cond)) { \
|
|
throw std::runtime_error( \
|
|
::onnxruntime::MlasShimMakeMessage( \
|
|
"ORT_ENFORCE(" #cond ") failed: ", ##__VA_ARGS__)); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ORT_NOT_IMPLEMENTED(...) ORT_THROW("not implemented: ", ##__VA_ARGS__)
|