File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ namespace runtime {
7272 */
7373void CleanDir (const std::string& dirname);
7474
75+ /* !
76+ * \brief ListDir get the list of files in a directory
77+ * \param dirname The root directory name
78+ * \return vector Files in directory.
79+ */
80+ std::vector<std::string> ListDir (const std::string& dirname);
81+
7582/* !
7683 * \brief buld a shared library if necessary
7784 *
@@ -123,6 +130,15 @@ RPCEnv::RPCEnv(const std::string& wd) {
123130 *rv = this ->GetPath (args[0 ]);
124131 });
125132
133+ TVM_REGISTER_GLOBAL (" tvm.rpc.server.listdir" ).set_body ([this ](TVMArgs args, TVMRetValue* rv) {
134+ std::string dir = this ->GetPath (args[0 ]);
135+ std::ostringstream os;
136+ for (auto d : ListDir (dir)) {
137+ os << d << " ," ;
138+ }
139+ *rv = os.str ();
140+ });
141+
126142 TVM_REGISTER_GLOBAL (" tvm.rpc.server.load_module" ).set_body ([this ](TVMArgs args, TVMRetValue* rv) {
127143 std::string file_name = this ->GetPath (args[0 ]);
128144 file_name = BuildSharedLibrary (file_name);
Original file line number Diff line number Diff line change @@ -145,6 +145,23 @@ def remove(self, path):
145145 self ._remote_funcs ["remove" ] = self .get_function ("tvm.rpc.server.remove" )
146146 self ._remote_funcs ["remove" ](path )
147147
148+ def listdir (self , path ):
149+ """ls files from remote temp folder.
150+
151+ Parameters
152+ ----------
153+ path: str
154+ The relative location to remote temp folder.
155+
156+ Returns
157+ -------
158+ dirs: str
159+ The files in the given directory with split token ','.
160+ """
161+ if "listdir" not in self ._remote_funcs :
162+ self ._remote_funcs ["listdir" ] = self .get_function ("tvm.rpc.server.listdir" )
163+ return self ._remote_funcs ["listdir" ](path )
164+
148165 def load_module (self , path ):
149166 """Load a remote module, the file need to be uploaded first.
150167
You can’t perform that action at this time.
0 commit comments