From c1e9ed61e40475e43beae7e9e930026e99620e19 Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Tue, 19 May 2020 09:27:14 +0900 Subject: [PATCH 1/2] [IOS] Fix build error of iOS RPC - Update to C++14 - Use the latest RPC protocol - Resolve CoreML dependency --- apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj | 16 ++++++++++++++-- apps/ios_rpc/tvmrpc/TVMRuntime.mm | 9 ++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj b/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj index 0c084902c0ff..b33c892cf002 100644 --- a/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj +++ b/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ C02637661F1C2690007247A9 /* TVMRuntime.mm in Sources */ = {isa = PBXBuildFile; fileRef = C02637651F1C2690007247A9 /* TVMRuntime.mm */; }; C02637691F1C26AF007247A9 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C02637681F1C26AF007247A9 /* ViewController.mm */; }; C05A2C891F1DCE0900D4798B /* tvmrpcLauncher.mm in Sources */ = {isa = PBXBuildFile; fileRef = C05A2C881F1DCE0900D4798B /* tvmrpcLauncher.mm */; }; + D7685AD324390EAE00D1469C /* CoreML.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D7685AD224390EAD00D1469C /* CoreML.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -62,6 +63,7 @@ C05A2C861F1DCE0900D4798B /* tvmrpcLauncher.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = tvmrpcLauncher.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C05A2C881F1DCE0900D4798B /* tvmrpcLauncher.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = tvmrpcLauncher.mm; sourceTree = ""; }; C05A2C8A1F1DCE0900D4798B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D7685AD224390EAD00D1469C /* CoreML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreML.framework; path = System/Library/Frameworks/CoreML.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -69,6 +71,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D7685AD324390EAE00D1469C /* CoreML.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -88,6 +91,7 @@ C026374D1F1C25E8007247A9 /* tvmrpc */, C05A2C871F1DCE0900D4798B /* tvmrpcLauncher */, C026374C1F1C25E8007247A9 /* Products */, + D7685AD124390EAD00D1469C /* Frameworks */, ); indentWidth = 2; sourceTree = ""; @@ -137,6 +141,14 @@ path = tvmrpcLauncher; sourceTree = ""; }; + D7685AD124390EAD00D1469C /* Frameworks */ = { + isa = PBXGroup; + children = ( + D7685AD224390EAD00D1469C /* CoreML.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -309,7 +321,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -358,7 +370,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; diff --git a/apps/ios_rpc/tvmrpc/TVMRuntime.mm b/apps/ios_rpc/tvmrpc/TVMRuntime.mm index 289450b30b9f..4260281fadb8 100644 --- a/apps/ios_rpc/tvmrpc/TVMRuntime.mm +++ b/apps/ios_rpc/tvmrpc/TVMRuntime.mm @@ -41,6 +41,9 @@ #include "../../../src/runtime/rpc/rpc_server_env.cc" #include "../../../src/runtime/rpc/rpc_session.cc" #include "../../../src/runtime/rpc/rpc_socket_impl.cc" +#include "../../../src/runtime/rpc/rpc_endpoint.cc" +#include "../../../src/runtime/rpc/rpc_local_session.cc" +#include "../../../src/runtime/rpc/rpc_channel.cc" // Graph runtime #include "../../../src/runtime/graph/graph_runtime.cc" // Metal @@ -82,9 +85,9 @@ size_t Recv(void* data, size_t size) final { FEventHandler CreateServerEventHandler(NSOutputStream* outputStream, std::string name, std::string remote_key) { std::unique_ptr ch(new NSStreamChannel(outputStream)); - std::shared_ptr sess = RPCSession::Create(std::move(ch), name, remote_key); + std::shared_ptr sess = RPCEndpoint::Create(std::move(ch), name, remote_key); return [sess](const std::string& in_bytes, int flag) { - return sess->ServerEventHandler(in_bytes, flag); + return sess->ServerAsyncIOEventHandler(in_bytes, flag); }; } @@ -115,7 +118,7 @@ void LaunchSyncServer() { std::string url, key; int port; CHECK(fs >> url >> port >> key) << "Invalid RPC config file " << name; - RPCConnect(url, port, "server:" + key)->ServerLoop(); + RPCConnect(url, port, "server:" + key, TVMArgs(nullptr, nullptr, 0))->ServerLoop(); } TVM_REGISTER_GLOBAL("tvm.rpc.server.workpath").set_body([](TVMArgs args, TVMRetValue* rv) { From 9b6a7ccbd0e171dd05aaed87126d93f9b894d91f Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Tue, 19 May 2020 11:44:16 +0900 Subject: [PATCH 2/2] Fix clang-format error --- apps/ios_rpc/tvmrpc/TVMRuntime.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/ios_rpc/tvmrpc/TVMRuntime.mm b/apps/ios_rpc/tvmrpc/TVMRuntime.mm index 4260281fadb8..d9b834ba13a6 100644 --- a/apps/ios_rpc/tvmrpc/TVMRuntime.mm +++ b/apps/ios_rpc/tvmrpc/TVMRuntime.mm @@ -37,13 +37,13 @@ #include "../../../src/runtime/workspace_pool.cc" // RPC server +#include "../../../src/runtime/rpc/rpc_channel.cc" +#include "../../../src/runtime/rpc/rpc_endpoint.cc" +#include "../../../src/runtime/rpc/rpc_local_session.cc" #include "../../../src/runtime/rpc/rpc_module.cc" #include "../../../src/runtime/rpc/rpc_server_env.cc" #include "../../../src/runtime/rpc/rpc_session.cc" #include "../../../src/runtime/rpc/rpc_socket_impl.cc" -#include "../../../src/runtime/rpc/rpc_endpoint.cc" -#include "../../../src/runtime/rpc/rpc_local_session.cc" -#include "../../../src/runtime/rpc/rpc_channel.cc" // Graph runtime #include "../../../src/runtime/graph/graph_runtime.cc" // Metal