Skip to content

Commit

Permalink
Cherry picks for release - 1.8.2, 2nd attempt (#8620)
Browse files Browse the repository at this point in the history
* Add test for iOS package (#7816)

* Add test for iOS package

* Add readme

* fix pep8 warning

* Addressed CR comments, fixed CI failure

* Address CR comments

* Update readme.md

* Update package name and readme, added comments to the podspec

* Add podspec template for ios package, update build settings (#7907)

* Add podspec template for ios package

* minor formatting update

* Add spec.source_files for header files

* Update spec.public_header_files to spec.source_files

* minor update

* Add iOS packaging pipeline (#8264)

Create a pipeline to produce the iOS package artifacts.

* [iOS] Packaging pipeline improvements. (#8324)

Updates to the iOS packaging pipeline:
- Make it harder to overwrite package archives accidentally when uploading (fails if the archive already exists)
- Only upload package archives for release builds
- Some clean up

* Add metadata_props to ORT model (#8340)

* Add metadata_props to ORT model

* Minor update

* Update python binding, and increase the minimal pipeline size threshold

* Fixed a small bug in serializing ir_version

* Remove temp ort.py.fbs and add it to .gitignore

* Add iOS/macOS static framework (#8357)

* Add ability to generate ios static framework

* Fix typos

* Add pod cache clean, update some comments of previous commit

* Fix CI failure with newly added cpuinfo library

* Update test model (CoreML requires node has a name)

* Addressed CR comments

* Fix iOS packaging pipeline failure (#8433)

* Fix optimizer crash (#8274)

* Update iOS packaging script to default build static framework, disable bitcode (#8533)

* default package build to static, disable bitcode

* fix pipeline failure

* Address CR comments

* Add HardSigmoid to mobile packages. Used by PyTorch MobileNet v3 (#8552)

* bump the version number to 1.8.2

* Change Windows GPU machine pool to onnxruntime-win-cuda11-0

* [Objective-C API] Fix ORTIsCoreMLExecutionProviderAvailable link error when used from Swift. (#8350)

Co-authored-by: Edward Chen <[email protected]>
Co-authored-by: RandySheriffH <[email protected]>
Co-authored-by: Scott McKay <[email protected]>
Co-authored-by: Changming Sun <[email protected]>
  • Loading branch information
5 people authored Aug 5, 2021
1 parent 96bb4b1 commit 5527805
Show file tree
Hide file tree
Showing 53 changed files with 1,947 additions and 140 deletions.
2 changes: 1 addition & 1 deletion VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.1
1.8.2
120 changes: 91 additions & 29 deletions cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,18 @@ elseif(onnxruntime_BUILD_APPLE_FRAMEWORK)
"${CMAKE_CURRENT_BINARY_DIR}/generated_source.c"
)

# create Info.plist for the framework and podspec for CocoaPods (optional)
set(MACOSX_FRAMEWORK_NAME "onnxruntime")
set(MACOSX_FRAMEWORK_IDENTIFIER "com.microsoft.onnxruntime")
configure_file(${REPO_ROOT}/cmake/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)

# Need to include CoreML as a weaklink for CocoaPods package if the EP is enabled
if(onnxruntime_USE_COREML)
set(APPLE_WEAK_FRAMEWORK "\\\"CoreML\\\"")
endif()
set(INFO_PLIST_PATH "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
configure_file(${REPO_ROOT}/cmake/Info.plist.in ${INFO_PLIST_PATH})
configure_file(
${REPO_ROOT}/tools/ci_build/github/apple/framework_info.json.template
${CMAKE_CURRENT_BINARY_DIR}/framework_info.json)
set_target_properties(onnxruntime PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
Expand Down Expand Up @@ -145,40 +153,50 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA)
# copy the header files one by one
foreach(h_ ${ANDROID_AAR_HEADERS})
get_filename_component(HEADER_NAME_ ${h_} NAME)
configure_file(${h_} ${ANDROID_HEADERS_DIR}/${HEADER_NAME_} COPYONLY)
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${ANDROID_HEADERS_DIR}/${HEADER_NAME_})
endforeach()
endif()

target_link_libraries(onnxruntime PRIVATE
onnxruntime_session
${onnxruntime_libs}
${PROVIDERS_ACL}
${PROVIDERS_ARMNN}
${PROVIDERS_COREML}
${PROVIDERS_DML}
${PROVIDERS_MIGRAPHX}
${PROVIDERS_NNAPI}
${PROVIDERS_NUPHAR}
${PROVIDERS_RKNPU}
${PROVIDERS_ROCM}
${PROVIDERS_VITISAI}
${PROVIDERS_INTERNAL_TESTING}
${onnxruntime_winml}
onnxruntime_optimizer
onnxruntime_providers
onnxruntime_util
${onnxruntime_tvm_libs}
onnxruntime_framework
onnxruntime_graph
onnxruntime_common
onnxruntime_mlas
onnxruntime_flatbuffers
${onnxruntime_EXTERNAL_LIBRARIES})
set(onnxruntime_INTERNAL_LIBRARIES
onnxruntime_session
${onnxruntime_libs}
${PROVIDERS_ACL}
${PROVIDERS_ARMNN}
${PROVIDERS_COREML}
${PROVIDERS_DML}
${PROVIDERS_MIGRAPHX}
${PROVIDERS_NNAPI}
${PROVIDERS_NUPHAR}
${PROVIDERS_RKNPU}
${PROVIDERS_ROCM}
${PROVIDERS_VITISAI}
${PROVIDERS_INTERNAL_TESTING}
${onnxruntime_winml}
onnxruntime_optimizer
onnxruntime_providers
onnxruntime_util
${onnxruntime_tvm_libs}
onnxruntime_framework
onnxruntime_graph
onnxruntime_common
onnxruntime_mlas
onnxruntime_flatbuffers
)

if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
target_link_libraries(onnxruntime PRIVATE onnxruntime_language_interop onnxruntime_pyop)
list(APPEND onnxruntime_INTERNAL_LIBRARIES
onnxruntime_language_interop
onnxruntime_pyop
)
endif()

# If you are linking a new library, please add it to the list onnxruntime_INTERNAL_LIBRARIES or onnxruntime_EXTERNAL_LIBRARIES,
# Please do not add a library directly to the target_link_libraries command
target_link_libraries(onnxruntime PRIVATE
${onnxruntime_INTERNAL_LIBRARIES}
${onnxruntime_EXTERNAL_LIBRARIES}
)

set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_SO_LINK_FLAG} ${onnxruntime_DELAYLOAD_FLAGS})
set_target_properties(onnxruntime PROPERTIES LINK_DEPENDS ${SYMBOL_FILE})

Expand All @@ -196,3 +214,47 @@ set_target_properties(onnxruntime PROPERTIES FOLDER "ONNXRuntime")
if (WINDOWS_STORE)
target_link_options(onnxruntime PRIVATE /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll)
endif()

# Assemble the Apple static framework (iOS and macOS)
if(onnxruntime_BUILD_APPLE_FRAMEWORK)
set(STATIC_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/static_libraries)
file(MAKE_DIRECTORY ${STATIC_LIB_DIR})

# Remove the existing files in the STATIC_LIB_DIR folder
file(GLOB _OLD_STATIC_LIBS ${STATIC_LIB_DIR}/*.a)
file(REMOVE "${_OLD_STATIC_LIBS}")

# Go through all the static libraries, and create symbolic links
foreach(_LIB ${onnxruntime_INTERNAL_LIBRARIES} ${onnxruntime_EXTERNAL_LIBRARIES})
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:${_LIB}> ${STATIC_LIB_DIR}/$<TARGET_LINKER_FILE_NAME:${_LIB}>)
endif()
endforeach()

if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}-${CMAKE_OSX_SYSROOT})
else() # macOS
set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()

# Assemble the static framework
set(STATIC_FRAMEWORK_DIR ${STATIC_FRAMEWORK_OUTPUT_DIR}/static_framework/onnxruntime.framework)
set(STATIC_FRAMEWORK_HEADER_DIR ${STATIC_FRAMEWORK_DIR}/Headers)
file(MAKE_DIRECTORY ${STATIC_FRAMEWORK_DIR})
# Remove all files under STATIC_FRAMEWORK_DIR (if any)
file(GLOB_RECURSE _OLD_STATIC_FRAMEWORK ${STATIC_FRAMEWORK_DIR}/*.*)
file(REMOVE "${_OLD_STATIC_FRAMEWORK}")

file(MAKE_DIRECTORY ${STATIC_FRAMEWORK_HEADER_DIR})

# copy the header files one by one, and the Info.plist
foreach(h_ ${APPLE_FRAMEWORK_HEADERS})
get_filename_component(HEADER_NAME_ ${h_} NAME)
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${STATIC_FRAMEWORK_HEADER_DIR}/${HEADER_NAME_})
endforeach()
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INFO_PLIST_PATH} ${STATIC_FRAMEWORK_DIR}/Info.plist)

# link the static library
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND libtool -static -o ${STATIC_FRAMEWORK_DIR}/onnxruntime *.a WORKING_DIRECTORY ${STATIC_LIB_DIR})
endif()
14 changes: 7 additions & 7 deletions cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ file(GLOB onnxruntime_providers_common_srcs CONFIGURE_DEPENDS
)

if(onnxruntime_USE_NUPHAR)
set(PROVIDERS_NUPHAR onnxruntime_providers_nuphar)
set(PROVIDERS_NUPHAR onnxruntime_providers_nuphar)
endif()
if(onnxruntime_USE_VITISAI)
set(PROVIDERS_VITISAI onnxruntime_providers_vitisai)
set(PROVIDERS_VITISAI onnxruntime_providers_vitisai)
endif()
if(onnxruntime_USE_CUDA)
set(PROVIDERS_CUDA onnxruntime_providers_cuda)
endif()
if(onnxruntime_USE_COREML)
set(PROVIDERS_COREML onnxruntime_providers_coreml)
set(PROVIDERS_COREML onnxruntime_providers_coreml onnxruntime_coreml_proto)
endif()
if(onnxruntime_USE_NNAPI_BUILTIN)
set(PROVIDERS_NNAPI onnxruntime_providers_nnapi)
Expand All @@ -75,7 +75,7 @@ if(onnxruntime_USE_RKNPU)
set(PROVIDERS_RKNPU onnxruntime_providers_rknpu)
endif()
if(onnxruntime_USE_DML)
set(PROVIDERS_DML onnxruntime_providers_dml)
set(PROVIDERS_DML onnxruntime_providers_dml)
endif()
if(onnxruntime_USE_MIGRAPHX)
set(PROVIDERS_MIGRAPHX onnxruntime_providers_migraphx)
Expand All @@ -84,13 +84,13 @@ if(onnxruntime_USE_WINML)
set(PROVIDERS_WINML onnxruntime_providers_winml)
endif()
if(onnxruntime_USE_ACL)
set(PROVIDERS_ACL onnxruntime_providers_acl)
set(PROVIDERS_ACL onnxruntime_providers_acl)
endif()
if(onnxruntime_USE_ARMNN)
set(PROVIDERS_ARMNN onnxruntime_providers_armnn)
set(PROVIDERS_ARMNN onnxruntime_providers_armnn)
endif()
if(onnxruntime_USE_ROCM)
set(PROVIDERS_ROCM onnxruntime_providers_rocm)
set(PROVIDERS_ROCM onnxruntime_providers_rocm)
endif()

source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_common_srcs} ${onnxruntime_providers_srcs})
Expand Down
10 changes: 9 additions & 1 deletion objectivec/include/ort_coreml_execution_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@

#import "ort_session.h"

NS_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif

/**
* Gets whether the CoreML execution provider is available.
*/
BOOL ORTIsCoreMLExecutionProviderAvailable(void);

#ifdef __cplusplus
}
#endif

NS_ASSUME_NONNULL_BEGIN

/**
* Options for configuring the CoreML execution provider.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,32 @@ def GraphDocString(self):
return self._tab.String(o + self._tab.Pos)
return None

def ModelStart(builder): builder.StartObject(9)
# Model
def MetadataProps(self, j):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
if o != 0:
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from ort_flatbuffers_py.experimental.fbs.StringStringEntry import StringStringEntry
obj = StringStringEntry()
obj.Init(self._tab.Bytes, x)
return obj
return None

# Model
def MetadataPropsLength(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
if o != 0:
return self._tab.VectorLen(o)
return 0

# Model
def MetadataPropsIsNone(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
return o == 0

def ModelStart(builder): builder.StartObject(10)
def ModelAddIrVersion(builder, irVersion): builder.PrependInt64Slot(0, irVersion, 0)
def ModelAddOpsetImport(builder, opsetImport): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(opsetImport), 0)
def ModelStartOpsetImportVector(builder, numElems): return builder.StartVector(4, numElems, 4)
Expand All @@ -120,4 +145,6 @@ def ModelAddModelVersion(builder, modelVersion): builder.PrependInt64Slot(5, mod
def ModelAddDocString(builder, docString): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(docString), 0)
def ModelAddGraph(builder, graph): builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(graph), 0)
def ModelAddGraphDocString(builder, graphDocString): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(graphDocString), 0)
def ModelAddMetadataProps(builder, metadataProps): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(metadataProps), 0)
def ModelStartMetadataPropsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def ModelEnd(builder): return builder.EndObject()
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: fbs

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class StringStringEntry(object):
__slots__ = ['_tab']

@classmethod
def GetRootAsStringStringEntry(cls, buf, offset):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = StringStringEntry()
x.Init(buf, n + offset)
return x

@classmethod
def StringStringEntryBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4F\x52\x54\x4D", size_prefixed=size_prefixed)

# StringStringEntry
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)

# StringStringEntry
def Key(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
return self._tab.String(o + self._tab.Pos)
return None

# StringStringEntry
def Value(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
return self._tab.String(o + self._tab.Pos)
return None

def StringStringEntryStart(builder): builder.StartObject(2)
def StringStringEntryAddKey(builder, key): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(key), 0)
def StringStringEntryAddValue(builder, value): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0)
def StringStringEntryEnd(builder): return builder.EndObject()
1 change: 1 addition & 0 deletions onnxruntime/core/flatbuffers/schema/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ort.py.fbs
10 changes: 8 additions & 2 deletions onnxruntime/core/flatbuffers/schema/ort.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ table Graph{
sparse_initializers:[SparseTensor];
}

table StringStringEntry {
key:string;
value:string;
}

table Model {
ir_version:int64;
opset_import:[OperatorSetId];
Expand All @@ -202,10 +207,11 @@ table Model {
domain:string;
model_version:int64;
doc_string:string;

graph:Graph;

graph_doc_string:string;
metadata_props:[StringStringEntry];
}

table KernelCreateInfos {
Expand Down
Loading

0 comments on commit 5527805

Please sign in to comment.