areusch commented on a change in pull request #5484:
URL: https://github.com/apache/incubator-tvm/pull/5484#discussion_r419618169
##########
File path: python/tvm/rpc/client.py
##########
@@ -183,28 +198,37 @@ class LocalSession(RPCSession):
need to be ran both locally and remotely.
"""
def __init__(self):
- # pylint: disable=super-init-not-called
- self.context = nd.context
- self.get_function = tvm._ffi.get_global_func
- self._temp = util.tempdir()
+ self._temp = server._server_env([])
+ RPCSession.__init__(self, _ffi_api.LocalSession())
- def upload(self, data, target=None):
- if isinstance(data, bytearray):
- if not target:
- raise ValueError("target must present when file is a
bytearray")
- blob = data
- else:
- blob = bytearray(open(data, "rb").read())
- if not target:
- target = os.path.basename(data)
- with open(self._temp.relpath(target), "wb") as f:
- f.write(blob)
- def download(self, path):
- return bytearray(open(self._temp.relpath(path), "rb").read())
+@tvm._ffi.register_func("rpc.PopenSession")
+def _popen_session(binary):
+ temp = util.tempdir()
- def load_module(self, path):
- return _load_module(self._temp.relpath(path))
+ if isinstance(binary, (bytes, bytearray)):
+ path_exec = temp.relpath("server.minrpc")
+ with open(path_exec, "wb") as outfile:
+ outfile.write(binary)
+ os.chmod(path_exec, stat.S_IXUSR)
+ path_exec = os.path.abspath(path_exec)
+ else:
+ path_exec = os.path.abspath(binary)
Review comment:
maybe we could at least do a existence check and check it is an
executable file here, since otherwise i'm not sure what error the user might
see from C? also, is abspath necessary?
----------------------------------------------------------------
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]