--- a/c10/core/Scalar.h +++ b/c10/core/Scalar.h @@ -80,7 +80,9 @@ static_assert( sizeof(void*) != 8 || std::is_same_v, "int64_t is the same as long on 64 bit Linux"); -#if LONG_MAX != INT_MAX +#if LONG_MAX == INT_MAX + Scalar(long vv) : Scalar(static_cast(vv), true) {} +#else Scalar(long long vv) : Scalar(vv, true) {} #endif /* not 32-bit system */ #endif --- a/torch/csrc/autograd/python_function.cpp +++ b/torch/csrc/autograd/python_function.cpp @@ -804,7 +804,7 @@ throw torch::TypeError( "save_for_backward can only save variables, but argument %ld is of " "type %s", - i, + static_cast(i), Py_TYPE(obj)->tp_name); } }