apeskov commented on a change in pull request #7876:
URL: https://github.com/apache/tvm/pull/7876#discussion_r651305686



##########
File path: apps/ios_rpc/tvmrpc/TVMRuntime.mm
##########
@@ -71,88 +73,19 @@ void LogMessageImpl(const std::string& file, int lineno, 
const std::string& mess
 namespace tvm {
 namespace runtime {
 
-class NSStreamChannel final : public RPCChannel {
- public:
-  explicit NSStreamChannel(NSOutputStream* stream) : stream_(stream) {}
-
-  size_t Send(const void* data, size_t size) final {
-    ssize_t nbytes = [stream_ write:reinterpret_cast<const uint8_t*>(data) 
maxLength:size];
-    if (nbytes < 0) {
-      NSLog(@"%@", [stream_ streamError].localizedDescription);
-      throw tvm::Error("Stream error");
-    }
-    return nbytes;
-  }
-
-  size_t Recv(void* data, size_t size) final {
-    LOG(FATAL) << "Do not allow explicit receive for";
-    return 0;
-  }
-
- private:
-  NSOutputStream* stream_;
-};
-
-FEventHandler CreateServerEventHandler(NSOutputStream* outputStream, 
std::string name,
-                                       std::string remote_key) {
-  std::unique_ptr<NSStreamChannel> ch(new NSStreamChannel(outputStream));
-  std::shared_ptr<RPCEndpoint> sess = RPCEndpoint::Create(std::move(ch), name, 
remote_key);
-  return [sess](const std::string& in_bytes, int flag) {
-    return sess->ServerAsyncIOEventHandler(in_bytes, flag);
-  };
-}
-
-// Runtime environment
-struct RPCEnv {
- public:
-  RPCEnv() {
-    NSString* path = NSTemporaryDirectory();
-    base_ = [path UTF8String];
-    if (base_[base_.length() - 1] != '/') {
-      base_ = base_ + '/';
-    }
-  }
-  // Get Path.
-  std::string GetPath(const std::string& file_name) { return base_ + 
file_name; }
-
- private:
-  std::string base_;
-};
-
-void LaunchSyncServer() {
-  // only load dylib from frameworks.
-  NSBundle* bundle = [NSBundle mainBundle];
-  NSString* base = [bundle privateFrameworksPath];
-  NSString* path = [base stringByAppendingPathComponent:@"tvm/rpc_config.txt"];
-  std::string name = [path UTF8String];
-  std::ifstream fs(name, std::ios::in);
-  std::string url, key;
-  int port;
-  ICHECK(fs >> url >> port >> key) << "Invalid RPC config file " << name;
-  RPCConnect(url, port, "server:" + key, TVMArgs(nullptr, nullptr, 
0))->ServerLoop();
-}
-
 TVM_REGISTER_GLOBAL("tvm.rpc.server.workpath").set_body([](TVMArgs args, 
TVMRetValue* rv) {
-  static RPCEnv env;
-  *rv = env.GetPath(args[0]);
+  std::string name = args[0];
+  std::string base = [NSTemporaryDirectory() UTF8String];
+  *rv = base + "/" + name;
 });
 
 TVM_REGISTER_GLOBAL("tvm.rpc.server.load_module").set_body([](TVMArgs args, 
TVMRetValue* rv) {
   std::string name = args[0];
-  std::string fmt = GetFileFormat(name, "");

Review comment:
       Previous version of this patch was designed before merging of patch with 
custom DSO loader. But current PR state keeps this line unchanged.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to