Skip to content

Commit 763026f

Browse files
authored
[NeoOnnx] Bump protobuf (#1115)
* [NeoOnnx] Bump protobuf Signed-off-by: Kirill Golikov <kirill.golikov@abbyy.com> * [NeoOnnx] Update Sources.txt Signed-off-by: Kirill Golikov <kirill.golikov@abbyy.com> --------- Signed-off-by: Kirill Golikov <kirill.golikov@abbyy.com>
1 parent 31c4f13 commit 763026f

File tree

6 files changed

+59
-65
lines changed

6 files changed

+59
-65
lines changed

Build/Sources.ThirdParty.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

NeoML/Python/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ if(NOT pybind11_POPULATED)
2727
endif()
2828

2929
# Build NeoML
30-
set(NeoML_INSTALL OFF CACHE BOOL "" FORCE)
31-
set(NeoML_BUILD_TESTS OFF CACHE BOOL "" FORCE)
32-
set(NeoOnnx_BUILD ON CACHE BOOL "" FORCE)
33-
if(LINUX)
34-
set(NeoOnnx_BUILD_SHARED OFF CACHE BOOL "" FORCE)
30+
set(NeoML_INSTALL OFF CACHE BOOL "" FORCE)
31+
set(NeoML_BUILD_TESTS OFF CACHE BOOL "" FORCE)
32+
set(NeoML_BUILD_SHARED OFF CACHE BOOL "" FORCE)
33+
set(NeoOnnx_BUILD ON CACHE BOOL "" FORCE)
34+
set(NeoOnnx_BUILD_SHARED OFF CACHE BOOL "" FORCE)
35+
36+
if(MSVC) # static linking the standard library
37+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
3538
endif()
39+
3640
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_BINARY_DIR}/NeoML)
3741

3842
# Build python module

NeoML/Python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_long_description():
110110
long_description=get_long_description(),
111111
long_description_content_type='text/markdown',
112112
url='http://github.com/neoml-lib/neoml',
113-
install_requires=['numpy>=2.0.2', 'scipy>=1.5.2', 'onnx==1.16.0', 'protobuf==3.20.*'],
113+
install_requires=['numpy>=2.0.2', 'scipy>=1.5.2', 'onnx==1.16.0', 'protobuf==5.28.*'],
114114
ext_modules=[CMakeExtension("neoml.PythonWrapper")],
115115
cmdclass={"build_ext": CMakeBuild},
116116
include_package_data=True,

NeoOnnx/src/CMakeLists.txt

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
22

3+
set(CMAKE_CXX_STANDARD 14)
4+
35
if(NeoOnnx_BUILD_SHARED)
46
add_library(${PROJECT_NAME} SHARED common.cpp)
57
else()
@@ -142,62 +144,70 @@ endif()
142144

143145
configure_target(${PROJECT_NAME})
144146

147+
# Have to first set the compile flags and then go through your subfolders.
148+
if(MSVC)
149+
target_compile_options(${PROJECT_NAME} PRIVATE /W2)
150+
if(NeoOnnx_BUILD_SHARED)
151+
target_compile_options(${PROJECT_NAME} PRIVATE /MD$<$<CONFIG:Debug>:d>)
152+
else()
153+
target_compile_options(${PROJECT_NAME} PRIVATE /MT$<$<CONFIG:Debug>:d>)
154+
endif()
155+
# Because of the code generated by protobuf
156+
set(CMAKE_CXX_FLAGS " /wd4946 /wd4251 /wd4141 /wd4068 /wd4530 /wd4715 /wd4018 /wd4267 /wd4267 ")
157+
elseif(LINUX OR DARWIN)
158+
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-pedantic -Wno-array-bounds)
159+
if(USE_FINE_OBJECTS)
160+
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-nonportable-include-path)
161+
endif()
162+
add_compile_options( -Wno-attributes )
163+
endif()
164+
145165
if(DEFINED ENV{Protobuf_ROOT} AND (IOS OR ANDROID))
146166
list(APPEND CMAKE_FIND_ROOT_PATH $ENV{Protobuf_ROOT})
147167
endif()
148168

169+
#----------------------------------------------------------------------------------------------------------------------
170+
171+
set(CMAKE_FOLDER "protobuf")
172+
173+
#--------------------------
149174
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
150175
set(CMAKE_UNITY_BUILD OFF)
151176
endif()
152177

153-
set(protobuf_BUILD_TESTS OFF CACHE BOOL "")
154-
set(protobuf_MSVC_STATIC_RUNTIME "${STATIC_NEOML}" CACHE BOOL "")
155-
set(protobuf_WITH_ZLIB OFF CACHE BOOL "")
156-
set(protobuf_BUILD_PROTOC_BINARIES ON CACHE BOOL "")
157-
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "")
178+
set(protobuf_INSTALL OFF CACHE BOOL "Install protobuf binaries and files" )
179+
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests" )
180+
set(protobuf_BUILD_LIBUPB OFF CACHE BOOL "Build libupb" )
181+
set(protobuf_BUILD_PROTOC_BINARIES ON CACHE BOOL "Build libprotoc and protoc compiler" )
182+
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared Libraries" )
183+
set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support" )
184+
set(protobuf_MSVC_STATIC_RUNTIME ON CACHE BOOL "Link static runtime libraries" )
185+
set(ABSL_IDE_FOLDER "protobuf/absl" CACHE BOOL "The IDE sub-folder" )
158186

159187
if(USE_FINE_OBJECTS)
160-
add_subdirectory("${FINE_ROOT}/ThirdParty/protobuf/cmake"
188+
add_subdirectory("${FINE_ROOT}/ThirdParty/protobuf"
161189
"${CMAKE_BINARY_DIR}/protobuf" EXCLUDE_FROM_ALL)
162190
else()
163191
include(FetchContent)
164192
FetchContent_Declare(
165193
protobuf
166194
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
167-
GIT_TAG v3.11.4
195+
GIT_TAG v28.0
168196
)
169197

170198
FetchContent_GetProperties(protobuf)
171199

172200
if(NOT protobuf_POPULATED)
173201
FetchContent_Populate(protobuf)
174-
add_subdirectory(${protobuf_SOURCE_DIR}/cmake ${protobuf_BINARY_DIR} EXCLUDE_FROM_ALL)
202+
add_subdirectory(${protobuf_SOURCE_DIR} ${protobuf_BINARY_DIR} EXCLUDE_FROM_ALL)
175203
endif()
176204
endif()
177205

178-
if(LINUX)
179-
target_compile_options(libprotobuf PRIVATE -Wno-stringop-overflow)
180-
target_compile_options(libprotobuf-lite PRIVATE -Wno-stringop-overflow)
181-
endif()
182-
183-
if(DARWIN)
184-
target_compile_options(libprotobuf PRIVATE -Wno-deprecated-declarations)
185-
target_compile_options(libprotobuf-lite PRIVATE -Wno-deprecated-declarations)
186-
endif()
187-
206+
#--------------------------
188207
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
189208
set(CMAKE_UNITY_BUILD ${NeoML_UNITY_BUILD})
190209
endif()
191210

192-
if(USE_FINE_OBJECTS)
193-
target_link_libraries(${PROJECT_NAME} PRIVATE FineObjects)
194-
195-
# Todo: properly link FineStlStaticPart if any problems occure
196-
if(MSVC)
197-
target_link_libraries(${PROJECT_NAME} PRIVATE "msvcprt$<$<CONFIG:Debug>:d>")
198-
endif()
199-
endif()
200-
201211
set(PROTO_DIR ${CMAKE_CURRENT_BINARY_DIR}/cpp_proto/${CMAKE_CFG_INTDIR})
202212
set(PROTO_SRCS ${PROTO_DIR}/onnx.pb.cc)
203213
set(PROTO_HDRS ${PROTO_DIR}/onnx.pb.h)
@@ -216,15 +226,15 @@ add_custom_command(
216226
target_sources(${PROJECT_NAME} PRIVATE ${PROTO_HDRS} ${PROTO_SRCS})
217227
set_property(SOURCE ${PROTO_HDRS} ${PROTO_SRCS} PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
218228

219-
if(MSVC)
220-
target_compile_options(${PROJECT_NAME} PRIVATE /W2)
221-
target_compile_options(${PROJECT_NAME} PRIVATE /MD$<$<CONFIG:Debug>:d>)
222-
# Because of the code generated by protobuf
223-
target_compile_options(${PROJECT_NAME} PRIVATE /wd4946 /wd4251)
224-
elseif(NOT WIN32)
225-
set_property(SOURCE ${PROTO_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-pedantic -Wno-array-bounds ")
226-
if(USE_FINE_OBJECTS)
227-
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-nonportable-include-path)
229+
unset(CMAKE_FOLDER)
230+
231+
#----------------------------------------------------------------------------------------------------------------------
232+
233+
if(USE_FINE_OBJECTS)
234+
target_link_libraries(${PROJECT_NAME} PRIVATE FineObjects)
235+
# TODO: properly link FineStlStaticPart if any problems occure
236+
if(MSVC)
237+
target_link_libraries(${PROJECT_NAME} PRIVATE "msvcprt$<$<CONFIG:Debug>:d>")
228238
endif()
229239
endif()
230240

@@ -261,12 +271,7 @@ if(NOT TARGET protobuf::libprotobuf)
261271
message(FATAL_ERROR "Protobuf not found!")
262272
endif()
263273

264-
# Fix for a known protobuf Windows dll issue https://github.com/protocolbuffers/protobuf/issues/2502
265-
if((Protobuf_LIBRARY MATCHES ".*dll") OR (Protobuf_LIBRARY MATCHES ".*DLL"))
266-
target_compile_definitions(${PROJECT_NAME} PRIVATE PROTOBUF_USE_DLLS)
267-
endif()
268-
269-
target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotobuf PUBLIC NeoML)
274+
target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotobuf ${protobuf_ABSL_USED_TARGETS} PUBLIC NeoML)
270275
if(ANDROID)
271276
target_link_libraries(${PROJECT_NAME} PRIVATE log)
272277
endif()

NeoOnnx/src/Operators/GatherOperator.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ limitations under the License.
1616
#include "../common.h"
1717
#pragma hdrstop
1818

19-
#include <algorithm>
20-
2119
#include "GatherOperator.h"
2220
#include "NeoOnnxCheck.h"
2321

@@ -57,7 +55,7 @@ void CGatherOperator::AddLayers( const CTensorArray& inputs, CDnn& dnn, CTensorA
5755
CPtr<const CTensorBase> data = inputs[0];
5856
CTensorLayout dataLayout;
5957
for( int i = 0; i < data->DimCount(); ++i ) {
60-
dataLayout.Add( static_cast<TBlobDim>( std::max( 0, indices->DimCount() - 1 ) + i ) );
58+
dataLayout.Add( static_cast<TBlobDim>( max( 0, indices->DimCount() - 1 ) + i ) );
6159
}
6260
if( axis != 0 ) {
6361
std::swap( dataLayout[0], dataLayout[axis] );

Sources.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ git;https://github.com/abbyyProduct/ThirdParty-MKL
1212
get;ThirdParty/MKL;/;MKL 2022.0.2 1.0.8.0
1313

1414
git;https://github.com/abbyyProduct/ThirdParty-protobuf
15-
get;ThirdParty/protobuf;/;v3.11.4
15+
get;ThirdParty/protobuf;/;protobuf-v28.0
1616

1717
git;https://github.com/abbyyProduct/Tools_Libs-NeoMLTest
1818
get;NeoMLTest;/;NeoMLTest-master 1.0.74.0

0 commit comments

Comments
 (0)