Fix AMD ALPR_OCR and custom model
This commit is contained in:
@@ -36,6 +36,57 @@ const int MAX_MISSING_SCREEN = 1000;
|
||||
|
||||
namespace ANSCENTER
|
||||
{
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// DirectML fatal-error detection
|
||||
//
|
||||
// AMD's DirectML EP can fail in several distinct ways that all leave the
|
||||
// Ort::Session permanently broken and require a fresh CPU-fallback session:
|
||||
//
|
||||
// 887A0005 DXGI_ERROR_DEVICE_REMOVED — adapter killed (RDP attach,
|
||||
// TDR, sleep/wake, driver swap). GetDeviceRemovedReason gives
|
||||
// the sub-cause but the device is gone either way.
|
||||
// 80004005 E_FAIL — generic D3D12 / DML failure. Seen from
|
||||
// DmlGraphFusionHelper::ExecuteOperator and
|
||||
// DmlCommandRecorder::ExecuteCommandList on AMD when the
|
||||
// driver couldn't compile/execute a fused subgraph or when
|
||||
// TDR fires mid-command-list. No structured sub-cause
|
||||
// available — must treat as device-fatal.
|
||||
//
|
||||
// Branding strings ("DmlFusedNode", "DmlGraphFusionHelper",
|
||||
// "DmlCommandRecorder") catch future failure modes that surface the same
|
||||
// way without us having to chase each new HRESULT.
|
||||
//
|
||||
// Used by every catch site that wraps Ort::Session::Run on AMD DML.
|
||||
// Centralised here so a new failure mode is handled once, not 4+ times.
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
inline bool IsDmlFatalError(const std::string& msg) {
|
||||
return msg.find("887A0005") != std::string::npos
|
||||
|| msg.find("80004005") != std::string::npos
|
||||
|| msg.find("DmlFusedNode") != std::string::npos
|
||||
|| msg.find("DmlGraphFusionHelper") != std::string::npos
|
||||
|| msg.find("DmlCommandRecorder") != std::string::npos
|
||||
|| msg.find("DmlExecutionProvider") != std::string::npos;
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// IsDmlDeviceRemoved — narrowly checks ONLY 887A0005
|
||||
// (DXGI_ERROR_DEVICE_REMOVED). This is the truly unrecoverable case:
|
||||
// the D3D12 adapter is gone (driver crashed, RDP attach killed the
|
||||
// device, sleep/wake torched the WDDM context). No amount of session
|
||||
// recreation will bring it back — only a process restart or CPU
|
||||
// fallback can recover.
|
||||
//
|
||||
// In contrast, 80004005 (E_FAIL) from DmlGraphFusionHelper /
|
||||
// DmlCommandRecorder is intermittent on AMD when the driver chokes on
|
||||
// a fused subgraph or TDR fires mid-command-list. A fresh DML
|
||||
// session typically clears it and resumes GPU inference — that's the
|
||||
// stay-on-GPU recovery path used by ANSONNXYOLO's catch blocks.
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
inline bool IsDmlDeviceRemoved(const std::string& msg) {
|
||||
return msg.find("887A0005") != std::string::npos
|
||||
|| msg.find("DXGI_ERROR_DEVICE_REMOVED") != std::string::npos;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, T>::type
|
||||
inline clamp(const T& value, const T& low, const T& high)
|
||||
|
||||
Reference in New Issue
Block a user