From b0150281c2427f18030c26aba0a9e38f12e951f2 Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Sun, 18 Feb 2024 21:41:25 +0900 Subject: [PATCH] [coreml-tools] Update to 7.1 (#177) * [coreml-tools] update to 7.1 * regenerate patches * [coreml-tools] update baseline * ci: test 'coreml-tools' * [coreml-tools] fix enumgen path --- ports/coreml-tools/fix-cmake.patch | 439 +++++++++++---------------- ports/coreml-tools/fix-sources.patch | 28 +- ports/coreml-tools/portfile.cmake | 4 +- ports/coreml-tools/vcpkg.json | 7 +- test/azure-port-ios.txt | 1 + versions/baseline.json | 4 +- versions/c-/coreml-tools.json | 5 + 7 files changed, 198 insertions(+), 290 deletions(-) diff --git a/ports/coreml-tools/fix-cmake.patch b/ports/coreml-tools/fix-cmake.patch index 8baacd66..0a7854c4 100644 --- a/ports/coreml-tools/fix-cmake.patch +++ b/ports/coreml-tools/fix-cmake.patch @@ -1,39 +1,46 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index b657197..ac60dd2 100644 +index d462525..1f97838 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,4 +1,4 @@ --cmake_minimum_required(VERSION 3.10.2) -+cmake_minimum_required(VERSION 3.14) - +@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.10.2) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) -@@ -14,7 +14,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - See: https://gitlab.kitware.com/cmake/community/wikis/FAQ#i-run-an-out-of-source-build-but-cmake-generates-in-source-anyway-why - ") - endif() -- + project(coremltools) +include(GNUInstallDirs) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) -@@ -31,24 +31,24 @@ if(HAS_CCACHE) + + if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(FATAL_ERROR " +@@ -31,34 +32,49 @@ if(HAS_CCACHE) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) endif() -add_subdirectory(deps) -+find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED) -+find_package(pybind11 CONFIG REQUIRED) -+find_package(nlohmann_json CONFIG REQUIRED) # nlohmann_json::nlohmann_json -+find_package(protobuf CONFIG REQUIRED) # protobuf::libprotobuf - add_subdirectory(mlmodel) +-add_subdirectory(mlmodel) ++find_package(Python3 COMPONENTS Interpreter REQUIRED) ++if(NOT CMAKE_CROSSCOMPILING) ++ find_package(Python3 COMPONENTS Development NumPy REQUIRED) ++ link_libraries(Python3::Python Python3::NumPy) ++endif() ++ ++find_package(pybind11 CONFIG) ++if(pybind11_FOUND) ++ include_directories(${pybind11_INCLUDE_DIRS}) ++ link_libraries(${pybind11_LIBRARIES}) ++ add_compile_definitions(${pybind11_DEFINITIONS}) ++endif() -find_package(PythonInterp) -find_package(PythonLibs) -- ++find_package(nlohmann_json CONFIG REQUIRED) # nlohmann_json::nlohmann_json ++link_libraries(nlohmann_json::nlohmann_json) + -message("Found python at ${PYTHON_EXECUTABLE}") -message("Found python version ${PYTHON_VERSION_STRING}") -message("Found python includes ${PYTHON_INCLUDE_DIRS}") ++find_package(protobuf CONFIG REQUIRED) # protobuf::libprotobuf ++ ++add_subdirectory(mlmodel) ++ +message(STATUS "Found python at ${Python3_EXECUTABLE}") +message(STATUS "Found python version ${Python3_VERSION}") +message(STATUS "Found python includes ${Python3_INCLUDE_DIRS}") @@ -47,13 +54,17 @@ index b657197..ac60dd2 100644 - ${PYTHON_INCLUDE_DIRS} + ${pybind11_INCLUDE_DIRS} ) -+link_libraries( -+ Python3::Python Python3::NumPy ${pybind11_LIBRARIES} nlohmann_json::nlohmann_json) -+add_compile_definitions(${pybind11_DEFINITIONS}) if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") -@@ -59,6 +59,7 @@ add_library(milstoragepython +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") ++ add_compile_options(-fobjc-arc) + endif() ++if(CMAKE_CROSSCOMPILING) ++ return() ++endif() # just libraries. no executables + + add_library(milstoragepython + SHARED milstoragepython/MilStorage.cpp milstoragepython/MilStoragePython.cpp ) @@ -61,17 +72,17 @@ index b657197..ac60dd2 100644 target_link_libraries(milstoragepython mlmodel -@@ -70,7 +71,8 @@ add_library(modelpackage +@@ -70,7 +86,8 @@ add_library(modelpackage modelpackage/src/utils/JsonMap.cpp modelpackage/src/ModelPackagePython.cpp ) - -+ install(TARGETS modelpackage DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++install(TARGETS modelpackage DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_compile_definitions(modelpackage PRIVATE CPU_ONLY=1 -@@ -78,7 +80,7 @@ target_compile_definitions(modelpackage +@@ -78,7 +95,7 @@ target_compile_definitions(modelpackage target_link_libraries(modelpackage mlmodel @@ -80,20 +91,54 @@ index b657197..ac60dd2 100644 ) if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) -@@ -157,6 +159,8 @@ if (APPLE AND CORE_VIDEO AND CORE_ML AND FOUNDATION) +@@ -132,21 +149,7 @@ find_library(CORE_VIDEO CoreVideo) + find_library(CORE_ML CoreML) + find_library(FOUNDATION Foundation) + +-if (APPLE AND CORE_VIDEO AND CORE_ML AND FOUNDATION) +- execute_process( +- COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())" +- RESULT_VARIABLE NUMPY_INCLUDE_STATUS +- OUTPUT_VARIABLE NUMPY_INCLUDE +- ) +- +- if("${NUMPY_INCLUDE}" STREQUAL "" OR NOT NUMPY_INCLUDE_STATUS EQUAL 0) +- message(FATAL_ERROR "Could not find numpy include path. Exit code: ${NUMPY_INCLUDE_STATUS}") +- endif() +- message("Found numpy include path at ${NUMPY_INCLUDE}") +- +- include_directories( +- ${NUMPY_INCLUDE} +- ) ++if (APPLE) + + add_library(coremlpython + SHARED +@@ -157,6 +160,7 @@ if (APPLE AND CORE_VIDEO AND CORE_ML AND FOUNDATION) coremlpython/CoreMLPythonUtils.mm coremlpython/CoreMLPythonUtils.h ) + install(TARGETS coremlpython DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+ target_link_libraries(coremlpython mlmodel ${CORE_VIDEO} diff --git a/cmake/coreml-utils.cmake b/cmake/coreml-utils.cmake -index a87a3bf..39c3957 100644 +index ab4679c..259b4ef 100644 --- a/cmake/coreml-utils.cmake +++ b/cmake/coreml-utils.cmake -@@ -25,40 +25,38 @@ function(coreml_add_build_proto proto_fn target_suffix) +@@ -20,35 +20,55 @@ + # to the list proto_depends in PARENT_SCOPE. + # + function(coreml_add_build_proto proto_fn target_suffix) ++ # some commands need mlmodel/enumgen host executable ++ if(CMAKE_CROSSCOMPILING) ++ find_program(ENUMGEN NAMES enumgen mlmodel/enumgen REQUIRED) ++ else() ++ set(ENUMGEN mlmodel${target_suffix}/enumgen) ++ endif() ++ + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}.pb.h COMMENT "Generating c++ sources from ${proto_fn}.proto into ${CMAKE_CURRENT_BINARY_DIR}/format/" @@ -103,22 +148,46 @@ index a87a3bf..39c3957 100644 -I${CMAKE_CURRENT_SOURCE_DIR}/format ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto - DEPENDS protoc - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h - COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_BINARY_DIR}/format/" +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +- ) +- add_custom_command( +- OUTPUT +- ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h +- COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_BINARY_DIR}/format/" - COMMAND ${CMAKE_BINARY_DIR}/deps/protobuf/cmake/protoc -+ COMMAND ${Protobuf_PROTOC_EXECUTABLE} - --plugin=protoc-gen-enum=mlmodel${target_suffix}/enumgen - --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ - -I${CMAKE_CURRENT_SOURCE_DIR}/format/ - ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto +- --plugin=protoc-gen-enum=mlmodel/enumgen +- --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ +- -I${CMAKE_CURRENT_SOURCE_DIR}/format/ +- ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto - DEPENDS enumgen protoc -+ DEPENDS enumgen WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ++ ++ if(NOT CMAKE_CROSSCOMPILING) ++ add_custom_command( ++ OUTPUT ++ ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h ++ COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_BINARY_DIR}/format/" ++ COMMAND ${Protobuf_PROTOC_EXECUTABLE} ++ --plugin=protoc-gen-enum=${ENUMGEN} ++ --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ ++ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ ++ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto ++ DEPENDS enumgen ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ ) ++ else() ++ add_custom_command( ++ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h ++ COMMAND ${Protobuf_PROTOC_EXECUTABLE} ++ --plugin=protoc-gen-enum=${ENUMGEN} ++ --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ ++ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ ++ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ ) ++ endif() ++ add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/coremltools${target_suffix}/proto/${proto_fn}_pb2.py @@ -128,10 +197,7 @@ index a87a3bf..39c3957 100644 --python_out=${CMAKE_BINARY_DIR}/coremltools${target_suffix}/proto -I${CMAKE_CURRENT_SOURCE_DIR}/format/ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -- COMMAND python -+ COMMAND ${Python3_EXECUTABLE} - -m lib2to3 - -wn +@@ -58,7 +78,6 @@ function(coreml_add_build_proto proto_fn target_suffix) --no-diff -f import ${CMAKE_BINARY_DIR}/coremltools${target_suffix}/${proto_fn}_pb2.py @@ -139,7 +205,7 @@ index a87a3bf..39c3957 100644 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) # For the CoreML framework we read the source file locations for these, and -@@ -67,36 +65,34 @@ function(coreml_add_build_proto proto_fn target_suffix) +@@ -67,26 +86,40 @@ function(coreml_add_build_proto proto_fn target_suffix) if(OVERWRITE_PB_SOURCE) add_custom_target(tgt_${proto_fn}_source ALL COMMENT "Generating c++ sources from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" @@ -149,20 +215,44 @@ index a87a3bf..39c3957 100644 -I${CMAKE_CURRENT_SOURCE_DIR}/format ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto - DEPENDS protoc - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - add_custom_target(tgt_${proto_fn}_enums ALL - COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +- ) +- add_custom_target(tgt_${proto_fn}_enums ALL +- COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" - COMMAND ${CMAKE_BINARY_DIR}/deps/protobuf/cmake/protoc -+ COMMAND ${Protobuf_PROTOC_EXECUTABLE} - --plugin=protoc-gen-enum=mlmodel${target_suffix}/enumgen - --enum_out=${CMAKE_CURRENT_SOURCE_DIR}/build/format/ - -I${CMAKE_CURRENT_SOURCE_DIR}/format/ - ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto +- --plugin=protoc-gen-enum=mlmodel/enumgen +- --enum_out=${CMAKE_CURRENT_SOURCE_DIR}/build/format/ +- -I${CMAKE_CURRENT_SOURCE_DIR}/format/ +- ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto - DEPENDS enumgen protoc -+ DEPENDS enumgen - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ++ ++ if(NOT CMAKE_CROSSCOMPILING) ++ add_custom_target(tgt_${proto_fn}_enums ALL ++ COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" ++ COMMAND ${Protobuf_PROTOC_EXECUTABLE} ++ --plugin=protoc-gen-enum=${ENUMGEN} ++ --enum_out=${CMAKE_CURRENT_SOURCE_DIR}/build/format/ ++ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ ++ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto ++ DEPENDS enumgen ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ ) ++ else() ++ add_custom_target(tgt_${proto_fn}_enums ALL ++ COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" ++ COMMAND ${Protobuf_PROTOC_EXECUTABLE} ++ --plugin=protoc-gen-enum=${ENUMGEN} ++ --enum_out=${CMAKE_CURRENT_SOURCE_DIR}/build/format/ ++ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ ++ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto ++ DEPENDS enumgen ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ ) ++ endif() ++ add_custom_target(tgt_${proto_fn}_python ALL COMMENT "Generating Python sources from ${proto_fn}.proto into ${CMAKE_SOURCE_DIR}/coremltools${target_suffix}/proto/" - COMMAND ${CMAKE_BINARY_DIR}/deps/protobuf/cmake/protoc @@ -170,35 +260,31 @@ index a87a3bf..39c3957 100644 --python_out=${CMAKE_SOURCE_DIR}/coremltools${target_suffix}/proto -I${CMAKE_CURRENT_SOURCE_DIR}/format/ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -- COMMAND python -+ COMMAND ${Python3_EXECUTABLE} - -m lib2to3 - -wn +@@ -96,8 +129,7 @@ function(coreml_add_build_proto proto_fn target_suffix) --no-diff -f import ${CMAKE_SOURCE_DIR}/coremltools${target_suffix}/proto/${proto_fn}_pb2.py - DEPENDS protoc - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) # Record dependencies for 'protosrc' target. + list(APPEND proto_depends tgt_${proto_fn}_source) diff --git a/mlmodel/CMakeLists.txt b/mlmodel/CMakeLists.txt -index df8fb48..fb3bb78 100644 +index 6d7b7fa..85cf718 100644 --- a/mlmodel/CMakeLists.txt +++ b/mlmodel/CMakeLists.txt -@@ -2,11 +2,10 @@ include("${CMAKE_SOURCE_DIR}/cmake/coreml-utils.cmake") +@@ -2,8 +2,7 @@ include("${CMAKE_SOURCE_DIR}/cmake/coreml-utils.cmake") include_directories( .. +- ../deps/FP16/include - ../deps/protobuf/src ++# ../deps/FP16/include src ) --add_definitions(-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER) -+add_compile_definitions(GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER) - - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS " \ -@@ -63,6 +62,7 @@ target_link_libraries(mlmodel_test +@@ -64,6 +63,7 @@ target_link_libraries(mlmodel_test add_executable(mlmodel_test_runner test_runner.cpp ) @@ -206,7 +292,7 @@ index df8fb48..fb3bb78 100644 target_link_libraries(mlmodel_test_runner mlmodel_test -@@ -71,8 +71,6 @@ target_link_libraries(mlmodel_test_runner +@@ -72,8 +72,6 @@ target_link_libraries(mlmodel_test_runner add_library(mlmodel STATIC @@ -215,12 +301,20 @@ index df8fb48..fb3bb78 100644 ${CMAKE_CURRENT_BINARY_DIR}/format/ArrayFeatureExtractor.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/format/AudioFeaturePrint.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/format/BayesianProbitRegressor.pb.cc -@@ -170,14 +168,14 @@ set_property(TARGET mlmodel +@@ -167,20 +165,22 @@ add_library(mlmodel + src/Validation/WordEmbeddingValidator.cpp + src/Validation/WordTaggerValidator.cpp + ) ++install(TARGETS mlmodel DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++# + + set_property(TARGET mlmodel + PROPERTY POSITION_INDEPENDENT_CODE ON ) target_link_libraries(mlmodel - libprotobuf-lite -+ protobuf::libprotobuf-lite ++ protobuf::libprotobuf-lite ) add_executable(enumgen @@ -232,7 +326,7 @@ index df8fb48..fb3bb78 100644 set(proto_files ArrayFeatureExtractor -@@ -215,7 +213,7 @@ set(proto_files +@@ -219,7 +218,7 @@ set(proto_files ) target_link_libraries(enumgen @@ -241,194 +335,3 @@ index df8fb48..fb3bb78 100644 ) option(OVERWRITE_PB_SOURCE -diff --git a/mlmodel/CMakeLists.txt b/mlmodel/CMakeLists.txt -index 6962924..68e7b35 100644 ---- a/mlmodel/CMakeLists.txt -+++ b/mlmodel/CMakeLists.txt -@@ -162,6 +162,7 @@ add_library(mlmodel - src/Validation/WordEmbeddingValidator.cpp - src/Validation/WordTaggerValidator.cpp - ) -+install(TARGETS mlmodel DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - set_property(TARGET mlmodel - PROPERTY POSITION_INDEPENDENT_CODE ON -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9c74125..31941c2 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -135,21 +135,6 @@ find_library(CORE_ML CoreML) - find_library(FOUNDATION Foundation) - - if (APPLE AND CORE_VIDEO AND CORE_ML AND FOUNDATION) -- execute_process( -- COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())" -- RESULT_VARIABLE NUMPY_INCLUDE_STATUS -- OUTPUT_VARIABLE NUMPY_INCLUDE -- ) -- -- if("${NUMPY_INCLUDE}" STREQUAL "" OR NOT NUMPY_INCLUDE_STATUS EQUAL 0) -- message(FATAL_ERROR "Could not find numpy include path. Exit code: ${NUMPY_INCLUDE_STATUS}") -- endif() -- message("Found numpy include path at ${NUMPY_INCLUDE}") -- -- include_directories( -- ${NUMPY_INCLUDE} -- ) -- - add_library(coremlpython - SHARED - coremlpython/CoreMLPython.mm -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 31941c2..fa77c10 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -31,12 +31,22 @@ if(HAS_CCACHE) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) - endif() - --find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED) --find_package(pybind11 CONFIG REQUIRED) -+find_package(Python3 COMPONENTS Interpreter REQUIRED) -+if(NOT CMAKE_CROSSCOMPILING) -+ find_package(Python3 COMPONENTS Development NumPy REQUIRED) -+ link_libraries(Python3::Python Python3::NumPy) -+endif() - find_package(nlohmann_json CONFIG REQUIRED) # nlohmann_json::nlohmann_json - find_package(protobuf CONFIG REQUIRED) # protobuf::libprotobuf - add_subdirectory(mlmodel) - -+find_package(pybind11 CONFIG) -+if(pybind11_FOUND) -+ include_directories(${pybind11_INCLUDE_DIRS}) -+ link_libraries(${pybind11_LIBRARIES}) -+ add_compile_definitions(${pybind11_DEFINITIONS}) -+endif() -+ - message(STATUS "Found python at ${Python3_EXECUTABLE}") - message(STATUS "Found python version ${Python3_VERSION}") - message(STATUS "Found python includes ${Python3_INCLUDE_DIRS}") -@@ -44,14 +54,16 @@ message(STATUS "Found python includes ${Python3_INCLUDE_DIRS}") - include_directories( - . - mlmodel/src -- ${pybind11_INCLUDE_DIRS} - ) - link_libraries( -- Python3::Python Python3::NumPy ${pybind11_LIBRARIES} nlohmann_json::nlohmann_json) --add_compile_definitions(${pybind11_DEFINITIONS}) -+ nlohmann_json::nlohmann_json -+ ) - - if(APPLE) -- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") -+ add_compile_options(-fobjc-arc) -+endif() -+if(CMAKE_CROSSCOMPILING) -+ return() # just libraries. no executables - endif() - - add_library(milstoragepython -@@ -71,7 +83,7 @@ add_library(modelpackage - modelpackage/src/utils/JsonMap.cpp - modelpackage/src/ModelPackagePython.cpp - ) -- install(TARGETS modelpackage DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+install(TARGETS modelpackage DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - target_compile_definitions(modelpackage - PRIVATE -diff --git a/cmake/coreml-utils.cmake b/cmake/coreml-utils.cmake -index 39c3957..9adcb95 100644 ---- a/cmake/coreml-utils.cmake -+++ b/cmake/coreml-utils.cmake -@@ -20,6 +20,12 @@ - # to the list proto_depends in PARENT_SCOPE. - # - function(coreml_add_build_proto proto_fn target_suffix) -+ # some commands need mlmodel/enumgen host executable -+ if(CMAKE_CROSSCOMPILING) -+ find_program(ENUMGEN NAMES enumgen mlmodel/enumgen REQUIRED) -+ else() -+ set(ENUMGEN mlmodel${target_suffix}/enumgen) -+ endif() - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}.pb.cc -@@ -31,18 +37,30 @@ function(coreml_add_build_proto proto_fn target_suffix) - ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) -- add_custom_command( -- OUTPUT -- ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h -- COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_BINARY_DIR}/format/" -- COMMAND ${Protobuf_PROTOC_EXECUTABLE} -- --plugin=protoc-gen-enum=mlmodel${target_suffix}/enumgen -- --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ -- -I${CMAKE_CURRENT_SOURCE_DIR}/format/ -- ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -- DEPENDS enumgen -- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -- ) -+ if(NOT CMAKE_CROSSCOMPILING) -+ add_custom_command( -+ OUTPUT -+ ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h -+ COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_BINARY_DIR}/format/" -+ COMMAND ${Protobuf_PROTOC_EXECUTABLE} -+ --plugin=protoc-gen-enum=mlmodel${target_suffix}/enumgen -+ --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ -+ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ -+ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -+ DEPENDS enumgen -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -+ ) -+ else() -+ add_custom_command( -+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/format/${proto_fn}_enum.h -+ COMMAND ${Protobuf_PROTOC_EXECUTABLE} -+ --plugin=protoc-gen-enum=${ENUMGEN} -+ --enum_out=${CMAKE_CURRENT_BINARY_DIR}/format/ -+ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ -+ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -+ ) -+ endif() - add_custom_command( - OUTPUT - ${CMAKE_BINARY_DIR}/coremltools${target_suffix}/proto/${proto_fn}_pb2.py -@@ -71,16 +89,27 @@ function(coreml_add_build_proto proto_fn target_suffix) - ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) -- add_custom_target(tgt_${proto_fn}_enums ALL -- COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" -+ if(NOT CMAKE_CROSSCOMPILING) -+ add_custom_target(tgt_${proto_fn}_enums ALL -+ COMMENT "Generating c++ enums from ${proto_fn}.proto into ${CMAKE_CURRENT_SOURCE_DIR}/build/format/" -+ COMMAND ${Protobuf_PROTOC_EXECUTABLE} -+ --plugin=protoc-gen-enum=mlmodel${target_suffix}/enumgen -+ --enum_out=${CMAKE_CURRENT_SOURCE_DIR}/build/format/ -+ -I${CMAKE_CURRENT_SOURCE_DIR}/format/ -+ ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -+ DEPENDS enumgen -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -+ ) -+ else() -+ add_custom_target(tgt_${proto_fn}_enums ALL - COMMAND ${Protobuf_PROTOC_EXECUTABLE} -- --plugin=protoc-gen-enum=mlmodel${target_suffix}/enumgen -+ --plugin=protoc-gen-enum=${ENUMGEN} - --enum_out=${CMAKE_CURRENT_SOURCE_DIR}/build/format/ - -I${CMAKE_CURRENT_SOURCE_DIR}/format/ - ${CMAKE_CURRENT_SOURCE_DIR}/format/${proto_fn}.proto -- DEPENDS enumgen -- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -- ) -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -+ ) -+ endif() - add_custom_target(tgt_${proto_fn}_python ALL - COMMENT "Generating Python sources from ${proto_fn}.proto into ${CMAKE_SOURCE_DIR}/coremltools${target_suffix}/proto/" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} diff --git a/ports/coreml-tools/fix-sources.patch b/ports/coreml-tools/fix-sources.patch index 6b30c241..a7baee35 100644 --- a/ports/coreml-tools/fix-sources.patch +++ b/ports/coreml-tools/fix-sources.patch @@ -1,18 +1,5 @@ -diff --git a/modelpackage/src/utils/JsonMap.cpp b/modelpackage/src/utils/JsonMap.cpp -index 400dcf2..c28e61c 100644 ---- a/modelpackage/src/utils/JsonMap.cpp -+++ b/modelpackage/src/utils/JsonMap.cpp -@@ -11,7 +11,7 @@ - #include - - #include "JsonMap.hpp" --#include "json.hpp" -+#include - - using namespace nlohmann; - diff --git a/mlmodel/src/Utils.hpp b/mlmodel/src/Utils.hpp -index 0a992b4..4b784e8 100644 +index 94792ed..4bc7204 100644 --- a/mlmodel/src/Utils.hpp +++ b/mlmodel/src/Utils.hpp @@ -62,7 +62,7 @@ namespace CoreML { @@ -76,3 +63,16 @@ index f6feb4b..5c07c55 100644 #include #include +diff --git a/modelpackage/src/utils/JsonMap.cpp b/modelpackage/src/utils/JsonMap.cpp +index 400dcf2..c28e61c 100644 +--- a/modelpackage/src/utils/JsonMap.cpp ++++ b/modelpackage/src/utils/JsonMap.cpp +@@ -11,7 +11,7 @@ + #include + + #include "JsonMap.hpp" +-#include "json.hpp" ++#include + + using namespace nlohmann; + diff --git a/ports/coreml-tools/portfile.cmake b/ports/coreml-tools/portfile.cmake index 29e4d380..fdd9edff 100644 --- a/ports/coreml-tools/portfile.cmake +++ b/ports/coreml-tools/portfile.cmake @@ -2,8 +2,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO apple/coremltools - REF 6.1 - SHA512 d739f6d8c021c5f2586122b9c4f3a0d96490dd83d4fa0c8e010d558ce32f272ac190f6d973116b896c5c27304890b63fc497b3043d3697d547e63418c417e21b + REF 7.1 + SHA512 64a8f9f9a47266d58b5c19fb7ad21458a481ea7d11309bd46ffc3390771f70c7ccb958abfdeedad86e7785fe320d532928441cc120d0e3570e96d149ec458b72 HEAD_REF master PATCHES fix-cmake.patch diff --git a/ports/coreml-tools/vcpkg.json b/ports/coreml-tools/vcpkg.json index 3b2c7a70..43346e25 100644 --- a/ports/coreml-tools/vcpkg.json +++ b/ports/coreml-tools/vcpkg.json @@ -1,9 +1,8 @@ { "name": "coreml-tools", - "version": "6.1", - "port-version": 3, - "description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)", - "homepage": "https://github.com/apple/coremltools", + "version": "7.1", + "description": "Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.", + "homepage": "https://coremltools.readme.io/", "license": "BSD-3-Clause", "supports": "osx | ios", "dependencies": [ diff --git a/test/azure-port-ios.txt b/test/azure-port-ios.txt index 184915d1..32c8d5c9 100644 --- a/test/azure-port-ios.txt +++ b/test/azure-port-ios.txt @@ -1,2 +1,3 @@ tensorflow-lite miniaudio +coreml-tools diff --git a/versions/baseline.json b/versions/baseline.json index ab7ff91a..391e511b 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -13,8 +13,8 @@ "port-version": 0 }, "coreml-tools": { - "baseline": "6.1", - "port-version": 3 + "baseline": "7.1", + "port-version": 0 }, "cpuinfo": { "baseline": "2023-11-29", diff --git a/versions/c-/coreml-tools.json b/versions/c-/coreml-tools.json index 6bf9d832..e19e634b 100644 --- a/versions/c-/coreml-tools.json +++ b/versions/c-/coreml-tools.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "6023229599457eec35aa0d825d4d30e23eb5e5ea", + "version": "7.1", + "port-version": 0 + }, { "git-tree": "fd52e153ea8b3fc2691fd49a8ab0315f2e5b89d2", "version": "6.1",