mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[BE] Enable Scalar.h compilation on 32-bit system (#142235)
By hiding ambiguous Scalar(long long) constructor behind `std::enable_if_t<sizeof(void *) == 8>` Followup after https://github.com/pytorch/pytorch/pull/141244 Test Plan: Run `printf "#include <c10/core/Scalar.h>\n c10::Scalar x(3);" | gcc -x c++ -std=c++17 -I. -Ibuild - -c` on ARMv7 system. Before this change it failed with: ``` In file included from <stdin>:1: ./c10/core/Scalar.h:83:3: error: ‘c10::Scalar::Scalar(long long int)’ cannot be overloaded with ‘c10::Scalar::Scalar(int64_t)’ 83 | Scalar(long long vv) : Scalar(vv, true) {} | ^~~~~~ ./c10/core/Scalar.h:50:3: note: previous declaration ‘c10::Scalar::Scalar(int64_t)’ 50 | Scalar(type vv) : Scalar(vv, true) {} | ^~~~~~ ./c10/core/ScalarType.h:288:3: note: in expansion of macro ‘DEFINE_IMPLICIT_CTOR’ 288 | _(int64_t, Long) \ | ^ ./c10/core/Scalar.h:52:3: note: in expansion of macro ‘AT_FORALL_SCALAR_TYPES_AND7’ 52 | AT_FORALL_SCALAR_TYPES_AND7( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/142235 Approved by: https://github.com/Skylion007
This commit is contained in:
parent
022cbf2f31
commit
3a3638be50
1 changed files with 2 additions and 0 deletions
|
|
@ -80,7 +80,9 @@ class C10_API Scalar {
|
|||
static_assert(
|
||||
sizeof(void*) != 8 || std::is_same_v<long, int64_t>,
|
||||
"int64_t is the same as long on 64 bit Linux");
|
||||
#if LONG_MAX != INT_MAX
|
||||
Scalar(long long vv) : Scalar(vv, true) {}
|
||||
#endif /* not 32-bit system */
|
||||
#endif
|
||||
|
||||
Scalar(uint16_t vv) : Scalar(vv, true) {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue