Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/cpp_rpc/rpc_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ namespace runtime {
*/
void CleanDir(const std::string& dirname);

/*!
* \brief ListDir get the list of files in a directory
* \param dirname The root directory name
* \return vector Files in directory.
*/
std::vector<std::string> ListDir(const std::string& dirname);

/*!
* \brief buld a shared library if necessary
*
Expand Down Expand Up @@ -123,6 +130,15 @@ RPCEnv::RPCEnv(const std::string& wd) {
*rv = this->GetPath(args[0]);
});

TVM_REGISTER_GLOBAL("tvm.rpc.server.listdir").set_body([this](TVMArgs args, TVMRetValue* rv) {
std::string dir = this->GetPath(args[0]);
std::ostringstream os;
for (auto d : ListDir(dir)) {
os << d << ",";
}
*rv = os.str();
});

TVM_REGISTER_GLOBAL("tvm.rpc.server.load_module").set_body([this](TVMArgs args, TVMRetValue* rv) {
std::string file_name = this->GetPath(args[0]);
file_name = BuildSharedLibrary(file_name);
Expand Down
17 changes: 17 additions & 0 deletions python/tvm/rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ def remove(self, path):
self._remote_funcs["remove"] = self.get_function("tvm.rpc.server.remove")
self._remote_funcs["remove"](path)

def listdir(self, path):
"""ls files from remote temp folder.

Parameters
----------
path: str
The relative location to remote temp folder.

Returns
-------
dirs: str
The files in the given directory with split token ','.
"""
if "listdir" not in self._remote_funcs:
self._remote_funcs["listdir"] = self.get_function("tvm.rpc.server.listdir")
return self._remote_funcs["listdir"](path)

def load_module(self, path):
"""Load a remote module, the file need to be uploaded first.

Expand Down