|
1 | 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt
|
2 |
| -index 8b5af303..8593fe4a 100644 |
| 2 | +index 47995579..6cc439f6 100644 |
3 | 3 | --- a/CMakeLists.txt
|
4 | 4 | +++ b/CMakeLists.txt
|
5 |
| -@@ -40,6 +40,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF) |
| 5 | +@@ -57,6 +57,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF) |
6 | 6 | option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
|
7 | 7 | option(ONNX_DISABLE_STATIC_REGISTRATION "Disable static registration for ONNX operator schemas." OFF)
|
8 | 8 | option(ONNX_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)
|
9 | 9 | +option(ONNX_MINIMAL_BUILD "Build only essential ONNX components" OFF)
|
10 | 10 | if(WIN32)
|
11 | 11 | option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime" OFF)
|
12 | 12 | endif()
|
13 |
| -@@ -461,14 +462,28 @@ relative_protobuf_generate_cpp(gen_onnx_data_proto |
14 |
| - list(APPEND ONNX_PROTO_SRCS ${__tmp_srcs}) |
15 |
| - list(APPEND ONNX_PROTO_HDRS ${__tmp_hdrs}) |
| 13 | +@@ -411,14 +412,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS |
| 14 | + |
| 15 | + add_library(onnx_proto ${ONNX_PROTO_SRCS}) |
16 | 16 |
|
17 | 17 | -file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
|
18 | 18 | -file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
|
@@ -45,115 +45,50 @@ index 8b5af303..8593fe4a 100644
|
45 | 45 | + list(APPEND ONNX_SRCS ${__tmp_srcs})
|
46 | 46 | +endif()
|
47 | 47 |
|
48 |
| - add_library(onnx_proto ${ONNX_PROTO_SRCS} ${ONNX_PROTO_HDRS}) |
49 |
| - add_dependencies(onnx_proto gen_onnx_operators_proto gen_onnx_data_proto) |
50 |
| -@@ -595,13 +610,6 @@ if(ONNX_BUILD_PYTHON) |
51 |
| - target_link_libraries(onnx_cpp2py_export PRIVATE ${Python3_LIBRARIES}) |
52 |
| - target_compile_options(onnx_cpp2py_export |
53 |
| - PRIVATE /MP |
54 |
| -- /wd4146 # unary minus operator applied to unsigned type, |
55 |
| -- # result still unsigned |
56 |
| -- /wd4244 # 'argument': conversion from 'google:: |
57 |
| -- # protobuf::uint64' to 'int', possible |
58 |
| -- # loss of data |
59 |
| -- /wd4267 # Conversion from 'size_t' to 'int', |
60 |
| -- # possible loss of data |
61 |
| - ${EXTRA_FLAGS}) |
62 |
| - add_msvc_runtime_flag(onnx_cpp2py_export) |
63 |
| - add_onnx_global_defines(onnx_cpp2py_export) |
64 |
| -@@ -618,23 +626,9 @@ endif() |
65 |
| - if(MSVC) |
66 |
| - target_compile_options(onnx_proto |
67 |
| - PRIVATE /MP |
68 |
| -- /wd4146 # unary minus operator applied to unsigned type, |
69 |
| -- # result still unsigned |
70 |
| -- /wd4244 #'argument': conversion from 'google:: |
71 |
| -- #protobuf::uint64' to 'int', possible |
72 |
| -- # loss of data |
73 |
| -- /wd4267 # Conversion from 'size_t' to 'int', |
74 |
| -- # possible loss of data |
75 |
| - ${EXTRA_FLAGS}) |
76 |
| - target_compile_options(onnx |
77 |
| - PRIVATE /MP |
78 |
| -- /wd4146 # unary minus operator applied to unsigned type, |
79 |
| -- # result still unsigned |
80 |
| -- /wd4244 # 'argument': conversion from 'google:: |
81 |
| -- # protobuf::uint64' to 'int', possible |
82 |
| -- # loss of data |
83 |
| -- /wd4267 # Conversion from 'size_t' to 'int', |
84 |
| -- # possible loss of data |
85 |
| - ${EXTRA_FLAGS}) |
86 |
| - add_msvc_runtime_flag(onnx_proto) |
87 |
| - add_msvc_runtime_flag(onnx) |
88 |
| -diff --git a/onnx/defs/nn/defs.cc b/onnx/defs/nn/defs.cc |
89 |
| -index 64366270..4aed9027 100644 |
90 |
| ---- a/onnx/defs/nn/defs.cc |
91 |
| -+++ b/onnx/defs/nn/defs.cc |
92 |
| -@@ -36,7 +36,7 @@ static const char* conv_transpose_auto_pad_doc = |
93 |
| - "on whether it is even or odd). In case the padding is an odd number, the extra " |
94 |
| - "padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER."; |
95 |
| - |
96 |
| --static void convPoolShapeInference( |
97 |
| -+void convPoolShapeInference( |
98 |
| - InferenceContext& ctx, |
99 |
| - bool use_dilation, |
100 |
| - bool require_kernel_shape, |
101 |
| -@@ -1102,7 +1102,7 @@ ONNX_OPERATOR_SET_SCHEMA( |
102 |
| - convPoolShapeInference(ctx, true, false, 0, 1); |
103 |
| - })); |
104 |
| - |
105 |
| --static void convTransposeShapeInference(InferenceContext& ctx) { |
106 |
| -+void convTransposeShapeInference(InferenceContext& ctx) { |
107 |
| - propagateElemTypeFromInputToOutput(ctx, 0, 0); |
108 |
| - |
109 |
| - // we need at least two inputs to have a shape for this inference. |
110 |
| -@@ -1462,7 +1462,7 @@ ONNX_OPERATOR_SET_SCHEMA( |
111 |
| - })); |
| 48 | + # Hide all symbols we don't need |
| 49 | + set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden) |
| 50 | +@@ -440,19 +455,6 @@ add_onnx_global_defines(onnx_proto) |
| 51 | + target_include_directories(onnx_proto PUBLIC |
| 52 | + $<BUILD_INTERFACE:${ONNX_ROOT}> |
| 53 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>) |
| 54 | +-if(MSVC) |
| 55 | +- # For disabling Protobuf related warnings |
| 56 | +- target_compile_options(onnx_proto PUBLIC |
| 57 | +- /wd4146 # unary minus operator applied to unsigned type, |
| 58 | +- # result still unsigned |
| 59 | +- /wd4244 # 'argument': conversion from 'google:: |
| 60 | +- # protobuf::uint64' to 'int', possible |
| 61 | +- # loss of data |
| 62 | +- /wd4267 # Conversion from 'size_t' to 'int', |
| 63 | +- # possible loss of data |
| 64 | +- /wd4141 # 'inline': used more than once |
| 65 | +- ) |
| 66 | +-endif() |
112 | 67 |
|
113 |
| - // For GlobalPool operations. |
114 |
| --static void globalPoolTypeShapeInference(InferenceContext& ctx) { |
115 |
| -+void globalPoolTypeShapeInference(InferenceContext& ctx) { |
116 |
| - propagateElemTypeFromInputToOutput(ctx, 0, 0); |
117 |
| - |
118 |
| - // needs at least one input with shape. |
| 68 | + if(CMAKE_SYSTEM_NAME STREQUAL "AIX") |
| 69 | + # whole-archive linker option not available on AIX. |
119 | 70 | diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc
|
120 |
| -index d8ca9a46..1eda4c70 100644 |
| 71 | +index 40635f97..44770774 100644 |
121 | 72 | --- a/onnx/defs/nn/old.cc
|
122 | 73 | +++ b/onnx/defs/nn/old.cc
|
123 |
| -@@ -4023,7 +4023,6 @@ ONNX_OPERATOR_SET_SCHEMA( |
| 74 | +@@ -4090,7 +4090,6 @@ ONNX_OPERATOR_SET_SCHEMA( |
124 | 75 | GroupNormalization,
|
125 | 76 | 18,
|
126 | 77 | OpSchema()
|
127 | 78 | - .Deprecate()
|
128 | 79 | .SetDoc(GroupNormalization_ver18_doc)
|
129 | 80 | .Attr("epsilon", "The epsilon value to use to avoid division by zero.", AttributeProto::FLOAT, 1e-5f)
|
130 | 81 | .Attr(
|
131 |
| -diff --git a/onnx/defs/rnn/defs.cc b/onnx/defs/rnn/defs.cc |
132 |
| -index c0ed3a39..6c8e2909 100644 |
133 |
| ---- a/onnx/defs/rnn/defs.cc |
134 |
| -+++ b/onnx/defs/rnn/defs.cc |
135 |
| -@@ -5,7 +5,7 @@ |
136 |
| - #include "onnx/defs/schema.h" |
137 |
| - |
138 |
| - namespace ONNX_NAMESPACE { |
139 |
| --static void RNNShapeInference(InferenceContext& ctx) { |
140 |
| -+void RNNShapeInference(InferenceContext& ctx) { |
141 |
| - TensorShapeProto::Dimension num_directions, seq_length, batch_size, hidden_size; |
142 |
| - |
143 |
| - auto direction = getAttribute(ctx, "direction", "forward"); |
144 | 82 | diff --git a/onnx/defs/schema.h b/onnx/defs/schema.h
|
145 |
| -index acf3aac7..5bef6e72 100644 |
| 83 | +index ddd95454..34647987 100644 |
146 | 84 | --- a/onnx/defs/schema.h
|
147 | 85 | +++ b/onnx/defs/schema.h
|
148 |
| -@@ -980,10 +980,7 @@ class OpSchemaRegistry final : public ISchemaRegistry { |
| 86 | +@@ -999,7 +999,7 @@ class OpSchemaRegistry final : public ISchemaRegistry { |
149 | 87 | class OpSchemaRegisterOnce final {
|
150 | 88 | public:
|
151 | 89 | // Export to cpp custom register macro
|
152 | 90 | - explicit OpSchemaRegisterOnce(
|
153 |
| -- OpSchema op_schema, |
154 |
| -- int opset_version_to_load = 0, |
155 |
| -- bool fail_duplicate_schema = true) { |
156 |
| -+ OpSchemaRegisterOnce(OpSchema op_schema, int opset_version_to_load = 0, bool fail_duplicate_schema = true) { |
157 |
| - OpSchemaRegisterNoExcept(std::move(op_schema), opset_version_to_load, fail_duplicate_schema); |
158 |
| - } |
159 |
| - static void |
| 91 | ++ OpSchemaRegisterOnce( |
| 92 | + OpSchema op_schema, |
| 93 | + int opset_version_to_load = 0, |
| 94 | + bool fail_duplicate_schema = true) { |
0 commit comments