blob: c9306ca424d51eb872fc415855b3d7c8328ea726 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
From 9809f77792517d0ace2874a84a181e8fe3766d8d Mon Sep 17 00:00:00 2001
From: Alejandro Alvarez Ayllon <a.alvarezayllon@gmail.com>
Date: Sat, 24 Feb 2024 14:53:33 +0100
Subject: [PATCH 4/4] Add fixes for use with onnxruntime
---
onnx/defs/schema.cc | 14 ++++++++++++++
onnx/onnxruntime_fix.h | 14 ++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 onnx/onnxruntime_fix.h
diff --git a/onnx/defs/schema.cc b/onnx/defs/schema.cc
index 74bd0a63..573d0901 100644
--- a/onnx/defs/schema.cc
+++ b/onnx/defs/schema.cc
@@ -21,8 +21,19 @@
#include "onnx/common/assertions.h"
#include "onnx/defs/parser.h"
+#include "onnx/onnxruntime_fix.h"
namespace ONNX_NAMESPACE {
+
+bool ONNXRuntimeFix::_static_registration_disabled = false;
+bool ONNXRuntimeFix::isStaticRegistrationDisabled() {
+ return _static_registration_disabled;
+}
+
+void ONNXRuntimeFix::disableStaticRegistration() {
+ _static_registration_disabled = true;
+}
+
// -1 means ONNX schema hasn't been loaded yet
// 0 means all versions of ONNX schema have been loaded
// Other positive integer means the ONNX schemas for the specified version have been loaded
@@ -1091,6 +1102,9 @@ OpName_Domain_Version_Schema_Map& OpSchemaRegistry::map() {
class SchemasRegisterer {
public:
SchemasRegisterer() {
+ // Check if static registration is actually disabled
+ if(ONNXRuntimeFix::isStaticRegistrationDisabled()) return;
+
// In debug builds, the number of schema registered in this constructor
// is compared against the number of calls to schema registration macros.
#ifndef NDEBUG
diff --git a/onnx/onnxruntime_fix.h b/onnx/onnxruntime_fix.h
new file mode 100644
index 00000000..2495b931
--- /dev/null
+++ b/onnx/onnxruntime_fix.h
@@ -0,0 +1,14 @@
+#pragma once
+
+namespace ONNX_NAMESPACE {
+
+class ONNXRuntimeFix {
+public:
+ static bool isStaticRegistrationDisabled();
+ static void disableStaticRegistration();
+
+private:
+ static bool _static_registration_disabled;
+};
+
+} // namespace ONNX_NAMESPACE
--
2.46.2
|