Commit 7761416f by eqy Committed by Tianqi Chen

[WIP] [RPC] clean up uploaded modules (#2121)

 [RPC] clean up uploaded modules
parent 83b24b5b
......@@ -467,6 +467,12 @@ def run_through_rpc(measure_input, build_result,
ctx.sync()
costs = time_f(*args).results
# clean up remote files
remote.remove(build_result.filename)
remote.remove(os.path.splitext(build_result.filename)[0] + '.so')
remote.remove('')
if len(costs) > 2: # remove largest and smallest value to reduce variance
costs = list(costs)
costs.sort()
......
......@@ -103,6 +103,19 @@ class RPCSession(object):
"tvm.rpc.server.download")
return self._remote_funcs["download"](path)
def remove(self, path):
"""Remove file from remote temp folder.
Parameters
----------
path: str
The relative location to remote temp folder.
"""
if "remove" not in self._remote_funcs:
self._remote_funcs["remove"] = self.get_function(
"tvm.rpc.server.remove")
self._remote_funcs["remove"](path)
def load_module(self, path):
"""Load a remote module, the file need to be uploaded first.
......
......@@ -142,5 +142,9 @@ void LoadMetaDataFromFile(
fs.close();
}
void RemoveFile(const std::string& file_name) {
std::remove(file_name.c_str());
}
} // namespace runtime
} // namespace tvm
......@@ -71,6 +71,12 @@ void SaveMetaDataToFile(
void LoadMetaDataFromFile(
const std::string& file_name,
std::unordered_map<std::string, FunctionInfo>* fmap);
/*!
* \brief Remove (unlink) a file.
* \param file_name The file name.
*/
void RemoveFile(const std::string& file_name);
} // namespace runtime
} // namespace tvm
#endif // TVM_RUNTIME_FILE_UTIL_H_
......@@ -35,5 +35,12 @@ TVM_REGISTER_GLOBAL("tvm.rpc.server.download")
*rv = arr;
});
TVM_REGISTER_GLOBAL("tvm.rpc.server.remove")
.set_body([](TVMArgs args, TVMRetValue *rv) {
std::string file_name = RPCGetPath(args[0]);
LOG(INFO) << "Remove " << file_name;
RemoveFile(file_name);
});
} // namespace runtime
} // namespace tvm
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment