Skip to content

Commit

Permalink
fix(build): torch 1.8 with cuda 11.3 string_view patch
Browse files Browse the repository at this point in the history
  • Loading branch information
beniz authored and mergify[bot] committed May 18, 2021
1 parent 2526892 commit 5002308
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ if (USE_TORCH)
${PYTORCH_PATCHES_PATH}/pytorch_16_new_logger.patch
${PYTORCH_PATCHES_PATH}/pytorch_16_use_new_logger.patch
${PYTORCH_PATCHES_PATH}/pytorch_14_namespace.patch
${PYTORCH_PATCHES_PATH}/pytorch_18_string_view.patch
)

message(STATUS "Configuring libtorch")
Expand Down
13 changes: 13 additions & 0 deletions patches/pytorch/pytorch_18_string_view.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/c10/util/string_view.h b/c10/util/string_view.h
index 2958887afc..140521553e 100644
--- a/c10/util/string_view.h
+++ b/c10/util/string_view.h
@@ -581,7 +581,7 @@ class basic_string_view final {
constexpr bool equals_(basic_string_view rhs) const {
// We don't use string_view::compare() here but implement it manually because
// only looking at equality allows for more optimized code.
-#if defined(__GNUC__)
+#if defined(__GNUC__) && !defined(__CUDACC__)
return size() == rhs.size() && 0 == __builtin_memcmp(data(), rhs.data(), size());
#elif __cpp_constexpr >= 201304
// if we are in C++14, write it iteratively. This is faster than the recursive C++11 implementation below.

0 comments on commit 5002308

Please sign in to comment.