diff --git a/0001-Workaround-NVCC-parse-failure-in-cast_op.patch b/0001-Workaround-NVCC-parse-failure-in-cast_op.patch new file mode 100644 index 0000000000000000000000000000000000000000..01c0fe0003ea0accd9172a79e94d5167206a8c47 --- /dev/null +++ b/0001-Workaround-NVCC-parse-failure-in-cast_op.patch @@ -0,0 +1,51 @@ +From e61ab44254dd585ba0f1bb6d056ecf2dbec7c24a Mon Sep 17 00:00:00 2001 +From: zhongling +Date: Thu, 2 Nov 2023 11:46:58 +0800 +Subject: [PATCH] Workaround NVCC parse failure in cast_op +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There is a bug in some CUDA versions (observed in CUDA 12.1 and 11.7 w/ +GCC 12.2), that makes cast_op fail to compile: +cast.h:45:120: error: expected template-name before ‘<’ token + +Defining the nested type as an alias and using it allows this to work +without any change in semantics. + +Fixes #4606 + +The alternative using a static_cast or similar fails due to ambiguity +with the const Foo& and Foo& operators (one of the tests) + +see also: https://github.com/pybind/pybind11/pull/4893/files +--- + third_party/pybind11/include/pybind11/cast.h | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/third_party/pybind11/include/pybind11/cast.h b/third_party/pybind11/include/pybind11/cast.h +index 430c62f3..0482e212 100644 +--- a/third_party/pybind11/include/pybind11/cast.h ++++ b/third_party/pybind11/include/pybind11/cast.h +@@ -39,13 +39,15 @@ using make_caster = type_caster>; + // Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T + template + typename make_caster::template cast_op_type cast_op(make_caster &caster) { +- return caster.operator typename make_caster::template cast_op_type(); ++ using result_t = typename make_caster::template cast_op_type; ++ return caster.operator result_t(); + } + template + typename make_caster::template cast_op_type::type> + cast_op(make_caster &&caster) { +- return std::move(caster).operator typename make_caster:: +- template cast_op_type::type>(); ++ using result_t = typename make_caster::template cast_op_type< ++ typename std::add_rvalue_reference::type>; ++ return std::move(caster).operator result_t(); + } + + template +-- +2.40.1 + diff --git a/pytorch.spec b/pytorch.spec index 3104847d3ba08ff6ef47c484a4f4ae2f1d7dbe39..c04ea59aa98c919ed22e036fcf9f6e5e159d6002 100644 --- a/pytorch.spec +++ b/pytorch.spec @@ -1,4 +1,4 @@ -%define anolis_release 3 +%define anolis_release 4 %global vcu_maj 12 %global vcu_min 1 @@ -17,6 +17,7 @@ License: BSD URL: https://pytorch.org Source0: https://github.com/pytorch/pytorch/releases/download/v%{version}/pytorch-v%{version}.tar.gz +Patch0: 0001-Workaround-NVCC-parse-failure-in-cast_op.patch BuildRequires: python3-devel cmake gcc-c++ BuildRequires: python3-typing-extensions python3-pyyaml python3-setuptools @@ -67,6 +68,7 @@ This package contains development files for pythorch. %prep %setup -q -n %{name}-v%{version} +%patch0 -p1 %build @@ -134,6 +136,9 @@ end %{python3_sitearch}/torch/share %changelog +* Thu Nov 2 2023 Zhongling He - 2.0.1-4 +- fix NVCC parse failure in cast_op + * Tue Aug 29 2023 Chunmei Xu - 2.0.1-3 - reflator spec file