From 6fcd99f6ed27115c771bb256ba43190142e9371c Mon Sep 17 00:00:00 2001 From: Guoyu Wang <62914304+gwang-msft@users.noreply.github.com> Date: Sun, 13 Sep 2020 17:28:12 -0700 Subject: [PATCH] Some minor updates for ORT mobile (#5146) * Minor update ios build instructions and other comments * Create shared string for nodearg name --- BUILD.md | 11 ++++++++--- onnxruntime/core/flatbuffers/ort.fbs | 2 +- onnxruntime/core/graph/graph.cc | 17 ++++++++++------- .../core/graph/graph_flatbuffers_utils.cc | 2 +- onnxruntime/core/graph/model.cc | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/BUILD.md b/BUILD.md index edd2118ba8..97df3bc6d0 100644 --- a/BUILD.md +++ b/BUILD.md @@ -143,7 +143,7 @@ Currently only supported on Windows and Linux. * dotnet is required for building csharp bindings and creating managed nuget package. Follow the instructions [here](https://dotnet.microsoft.com/download) to download dotnet. Tested with versions 2.1 and 3.1. * nuget.exe. Follow the instructions [here](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools#nugetexe-cli) to download nuget * On Windows, downloading nuget is straightforward and simply following the instructions above should work. - * On Linux, nuget relies on Mono runtime and therefore this needs to be setup too. Above link has all the information to setup Mono and nuget. The instructions can directly be found [here](https://www.mono-project.com/docs/getting-started/install/). In some cases it is required to run `sudo apt-get install mono-complete` after installing mono. + * On Linux, nuget relies on Mono runtime and therefore this needs to be setup too. Above link has all the information to setup Mono and nuget. The instructions can directly be found [here](https://www.mono-project.com/docs/getting-started/install/). In some cases it is required to run `sudo apt-get install mono-complete` after installing mono. ### Build Instructions #### Windows @@ -1053,21 +1053,26 @@ Android NNAPI Execution Provider can be built using building commands in [Androi * iOS simulator with x86_64 architecture armv7, armv7s and i386 architectures are not currently supported. + + tvOS and watchOS platforms are not currently supported. * apple_deploy_target Specify the minimum version of the target platform (iOS) on which the target binaries are to be deployed. +* Code Signing + + The onnxruntime library is not code signed, it may be required or desired to code sign the library for iOS devices. For more information, see [Code Signing](https://developer.apple.com/support/code-signing/). #### Build Instructions Run one of the following build scripts from the ONNX Runtime repository root, ##### Cross build for iOS device ``` /build.sh --config --use_xcode \ - --ios --ios_sysroot iphoneos --osx_arch arm64 --apple_deploy_target 12 + --ios --ios_sysroot iphoneos --osx_arch arm64 --apple_deploy_target ``` ##### Cross build for iOS simulator ``` /build.sh --config --use_xcode \ - --ios --ios_sysroot iphonesimulator --osx_arch x86_64 --apple_deploy_target 12 + --ios --ios_sysroot iphonesimulator --osx_arch x86_64 --apple_deploy_target ``` --- diff --git a/onnxruntime/core/flatbuffers/ort.fbs b/onnxruntime/core/flatbuffers/ort.fbs index cf946fb9a8..163a0da6df 100644 --- a/onnxruntime/core/flatbuffers/ort.fbs +++ b/onnxruntime/core/flatbuffers/ort.fbs @@ -217,7 +217,7 @@ table SessionState { } table InferenceSession { - // This is the ort format model version + // This is the ORT format model version // The version number is defined as kOrtModelVersion in /onnxruntime/core/session/inference_session.cc // Please update it when there is a change to this schema which will break the compatibilites ort_version:string; diff --git a/onnxruntime/core/graph/graph.cc b/onnxruntime/core/graph/graph.cc index d37c8553d2..95e66aa4c8 100644 --- a/onnxruntime/core/graph/graph.cc +++ b/onnxruntime/core/graph/graph.cc @@ -492,12 +492,13 @@ Status Node::SaveToOrtFormat(flatbuffers::FlatBufferBuilder& builder, } auto GetNodeArgsOrtFormat = [&builder](const std::vector& src) { - std::vector node_args(src.size()); + std::vector> node_args(src.size()); std::transform(src.cbegin(), src.cend(), node_args.begin(), - [](const NodeArg* nodearg) { - return nodearg->Name(); + [&builder](const NodeArg* nodearg) { + // NodeArg's name will be used by multiple places, create shared string + return builder.CreateSharedString(nodearg->Name()); }); - return builder.CreateVectorOfStrings(node_args); + return builder.CreateVector(node_args); }; auto name = builder.CreateString(name_); @@ -2706,10 +2707,12 @@ std::string Graph::GenerateNodeArgName(const std::string& base_name) { static flatbuffers::Offset>> SaveInputsOutputsToOrtFormat(flatbuffers::FlatBufferBuilder& builder, const std::vector& src) { - std::vector vec(src.size()); + std::vector> vec(src.size()); std::transform(src.cbegin(), src.cend(), vec.begin(), - [](const NodeArg* entry) { return entry->Name(); }); - return builder.CreateVectorOfStrings(vec); + [&builder](const NodeArg* entry) { + return builder.CreateSharedString(entry->Name()); + }); + return builder.CreateVector(vec); } common::Status Graph::SaveToOrtFormat(flatbuffers::FlatBufferBuilder& builder, diff --git a/onnxruntime/core/graph/graph_flatbuffers_utils.cc b/onnxruntime/core/graph/graph_flatbuffers_utils.cc index bb346a2745..f97f7b39e0 100644 --- a/onnxruntime/core/graph/graph_flatbuffers_utils.cc +++ b/onnxruntime/core/graph/graph_flatbuffers_utils.cc @@ -124,7 +124,7 @@ static Status SaveTypeInfoOrtFormat(flatbuffers::FlatBufferBuilder& builder, Status SaveValueInfoOrtFormat(flatbuffers::FlatBufferBuilder& builder, const ValueInfoProto& value_info_proto, flatbuffers::Offset& fbs_value_info) { - auto name = builder.CreateString(value_info_proto.name()); + auto name = builder.CreateSharedString(value_info_proto.name()); auto doc_string = builder.CreateString(value_info_proto.doc_string()); flatbuffers::Offset type_info = 0; // 0 indicates null if (value_info_proto.has_type()) { diff --git a/onnxruntime/core/graph/model.cc b/onnxruntime/core/graph/model.cc index 1912d25c6c..1fea9ba4e8 100644 --- a/onnxruntime/core/graph/model.cc +++ b/onnxruntime/core/graph/model.cc @@ -545,7 +545,7 @@ common::Status Model::SaveToOrtFormat(flatbuffers::FlatBufferBuilder& builder, flatbuffers::Offset& fbs_model) const { auto producer_name = builder.CreateString(model_proto_.producer_name()); auto producer_version = builder.CreateString(model_proto_.producer_version()); - auto domain = builder.CreateString(model_proto_.domain()); + auto domain = builder.CreateSharedString(model_proto_.domain()); auto doc_string = builder.CreateString(model_proto_.doc_string()); std::vector> op_set_ids_vec;