You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/02/02 05:38:56 UTC

[GitHub] [tvm] fantasyRqg opened a new pull request #7390: fix:getcwd not work on android platform

fantasyRqg opened a new pull request #7390:
URL: https://github.com/apache/tvm/pull/7390


   In cpp_rpc `getcwd` not work on android platform , just get `"\"`
   
   relate link: https://stackoverflow.com/questions/6276933/getfilesdir-from-ndk
   
   
   @vinx13 @tqchen 
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on a change in pull request #7390: fix:getcwd not work on android platform

Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #7390:
URL: https://github.com/apache/tvm/pull/7390#discussion_r595641218



##########
File path: apps/cpp_rpc/rpc_env.cc
##########
@@ -86,7 +86,13 @@ void CleanDir(const std::string& dirname);
 std::string BuildSharedLibrary(std::string file_in);
 
 RPCEnv::RPCEnv() {
-#ifndef _WIN32
+#if defined(ANDROID) || defined(__ANDROID__)
+  char cwd[PATH_MAX];
+  auto cmdline = fopen("/proc/self/cmdline", "r");
+  fread(cwd, 1, sizeof(cwd), cmdline);
+  fclose(cmdline);
+  base_ = "/data/data/" + std::string(cwd) + "/cache/rpc";
+#elif !defined(_WIN32)

Review comment:
       @csullivan great catch, can you send a new PR to fix this problem?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7390: fix:getcwd not work on android platform

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7390:
URL: https://github.com/apache/tvm/pull/7390#issuecomment-795599497


   Thank you @fantasyRqg !


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] csullivan commented on a change in pull request #7390: fix:getcwd not work on android platform

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #7390:
URL: https://github.com/apache/tvm/pull/7390#discussion_r596535887



##########
File path: apps/cpp_rpc/rpc_env.cc
##########
@@ -86,7 +86,13 @@ void CleanDir(const std::string& dirname);
 std::string BuildSharedLibrary(std::string file_in);
 
 RPCEnv::RPCEnv() {
-#ifndef _WIN32
+#if defined(ANDROID) || defined(__ANDROID__)
+  char cwd[PATH_MAX];
+  auto cmdline = fopen("/proc/self/cmdline", "r");
+  fread(cwd, 1, sizeof(cwd), cmdline);
+  fclose(cmdline);
+  base_ = "/data/data/" + std::string(cwd) + "/cache/rpc";
+#elif !defined(_WIN32)

Review comment:
       Absolutely, please allow me some time.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] csullivan commented on a change in pull request #7390: fix:getcwd not work on android platform

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #7390:
URL: https://github.com/apache/tvm/pull/7390#discussion_r595605745



##########
File path: apps/cpp_rpc/rpc_env.cc
##########
@@ -86,7 +86,13 @@ void CleanDir(const std::string& dirname);
 std::string BuildSharedLibrary(std::string file_in);
 
 RPCEnv::RPCEnv() {
-#ifndef _WIN32
+#if defined(ANDROID) || defined(__ANDROID__)
+  char cwd[PATH_MAX];
+  auto cmdline = fopen("/proc/self/cmdline", "r");
+  fread(cwd, 1, sizeof(cwd), cmdline);
+  fclose(cmdline);
+  base_ = "/data/data/" + std::string(cwd) + "/cache/rpc";
+#elif !defined(_WIN32)

Review comment:
       This change has the effect of now requiring a user to provide a target path to `RPCSession.upload(..., target=path)`, when running from `/data/local/tmp` for example. Without providing the target path, the `/data/data` prefix is always prepended resulting in errors like: 
   ```
      Check failed: !fs.fail() == false: Cannot open /data/data//data/local/tmp/tvm_rpc/cache/rpc/dev_lib_cl.so
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] tqchen merged pull request #7390: fix:getcwd not work on android platform

Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #7390:
URL: https://github.com/apache/tvm/pull/7390


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] csullivan commented on a change in pull request #7390: fix:getcwd not work on android platform

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #7390:
URL: https://github.com/apache/tvm/pull/7390#discussion_r595605745



##########
File path: apps/cpp_rpc/rpc_env.cc
##########
@@ -86,7 +86,13 @@ void CleanDir(const std::string& dirname);
 std::string BuildSharedLibrary(std::string file_in);
 
 RPCEnv::RPCEnv() {
-#ifndef _WIN32
+#if defined(ANDROID) || defined(__ANDROID__)
+  char cwd[PATH_MAX];
+  auto cmdline = fopen("/proc/self/cmdline", "r");
+  fread(cwd, 1, sizeof(cwd), cmdline);
+  fclose(cmdline);
+  base_ = "/data/data/" + std::string(cwd) + "/cache/rpc";
+#elif !defined(_WIN32)

Review comment:
       This change has the effect of now requiring a user to provide a target path to `RPCSession.upload(target=path)`, when running from `/data/local/tmp` for example. Without providing the target path, the `/data/data` prefix is always prepended resulting in errors like: 
   ```
      Check failed: !fs.fail() == false: Cannot open /data/data//data/local/tmp/tvm_rpc/cache/rpc/dev_lib_cl.so
   ```




----------------------------------------------------------------
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:
users@infra.apache.org