You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by li...@apache.org on 2020/06/21 21:43:55 UTC

[incubator-tvm] branch v0.6 updated: [BACKPORT-0.6] Some Windows and MSVC fixes (#5870)

This is an automated email from the ASF dual-hosted git repository.

liuyizhi pushed a commit to branch v0.6
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/v0.6 by this push:
     new 8de4c51  [BACKPORT-0.6] Some Windows and MSVC fixes (#5870)
8de4c51 is described below

commit 8de4c51be7bc6e9bb2856e3287c5ccb0fe7166b2
Author: Yizhi Liu <li...@apache.org>
AuthorDate: Sun Jun 21 14:43:47 2020 -0700

    [BACKPORT-0.6] Some Windows and MSVC fixes (#5870)
    
    Co-authored-by: kice <ws...@gmail.com>
    
    Co-authored-by: kice <ws...@gmail.com>
---
 python/tvm/_ffi/base.py      | 9 +++++++--
 src/runtime/c_runtime_api.cc | 7 +++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/python/tvm/_ffi/base.py b/python/tvm/_ffi/base.py
index 39d211b..66a8927 100644
--- a/python/tvm/_ffi/base.py
+++ b/python/tvm/_ffi/base.py
@@ -35,8 +35,13 @@ if sys.version_info[0] == 3:
     # this function is needed for python3
     # to convert ctypes.char_p .value back to python str
     if sys.platform == "win32":
-        encoding = 'cp' + str(ctypes.cdll.kernel32.GetACP())
-        py_str = lambda x: x.decode(encoding)
+        def _py_str(x):
+            try:
+                return x.decode('utf-8')
+            except UnicodeDecodeError:
+                encoding = 'cp' + str(ctypes.cdll.kernel32.GetACP())
+                return x.decode(encoding)
+        py_str = _py_str
     else:
         py_str = lambda x: x.decode('utf-8')
 else:
diff --git a/src/runtime/c_runtime_api.cc b/src/runtime/c_runtime_api.cc
index 3608fce..f1d5435 100644
--- a/src/runtime/c_runtime_api.cc
+++ b/src/runtime/c_runtime_api.cc
@@ -235,7 +235,14 @@ std::string NormalizeError(std::string err_msg) {
     if (!(is >> line)) return false;
     // get filename
     while (is.peek() == ' ') is.get();
+#ifdef _MSC_VER  // handle volume separator ":" in Windows path
+    std::string drive;
+    if (!getline(is, drive, ':')) return false;
     if (!getline(is, file_name, ':')) return false;
+    file_name = drive + ":" + file_name;
+#else
+    if (!getline(is, file_name, ':')) return false;
+#endif
     // get line number
     if (!(is >> line_number)) return false;
     // get rest of the message.