mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Reland] [1/N] fix clang-tidy warnings in torch/csrc (#108114)
Reland of PR #107648 with auto replaced with Py_ssize_t in eval_frame.c. This PR applies fixes to some found issues by clang-tidy in torch/csrc. Pull Request resolved: https://github.com/pytorch/pytorch/pull/108114 Approved by: https://github.com/Skylion007
This commit is contained in:
@ -131,7 +131,7 @@ PyObject* THCPModule_getDevice_wrap(PyObject* self, PyObject* noargs) {
|
||||
HANDLE_TH_ERRORS
|
||||
torch::utils::cuda_lazy_init();
|
||||
// NOLINTNEXTLINE(bugprone-signed-char-misuse)
|
||||
auto device = static_cast<int>(c10::cuda::current_device());
|
||||
auto device = static_cast<int32_t>(c10::cuda::current_device());
|
||||
return THPUtils_packInt32(device);
|
||||
END_HANDLE_TH_ERRORS
|
||||
}
|
||||
@ -269,8 +269,7 @@ PyObject* THCPModule_setStream_wrap(
|
||||
auto stream = at::cuda::CUDAStream::unpack3(
|
||||
stream_id, device_index, static_cast<c10::DeviceType>(device_type));
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-signed-char-misuse)
|
||||
auto device = static_cast<int>(c10::cuda::current_device());
|
||||
auto device = c10::cuda::current_device();
|
||||
if (device != stream.device_index()) {
|
||||
THCPModule_setDevice(stream.device_index());
|
||||
}
|
||||
@ -310,9 +309,7 @@ PyObject* THCPModule_cudaCachingAllocator_raw_alloc(
|
||||
return nullptr;
|
||||
}
|
||||
auto size = PyLong_AsSsize_t(size_o);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
cudaStream_t stream = static_cast<cudaStream_t>(PyLong_AsVoidPtr(stream_o));
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
void* mem =
|
||||
c10::cuda::CUDACachingAllocator::raw_alloc_with_stream(size, stream);
|
||||
return PyLong_FromVoidPtr(mem);
|
||||
|
Reference in New Issue
Block a user