8000 [SDPA][EZ] Abate narrowing conversion warning spam in `flash_api.cpp`… · pytorch/pytorch@e802b29 · GitHub
[go: up one dir, main page]

Skip to content

Commit e802b29

Browse files
eqypytorchmergebot
authored andcommitted
[SDPA][EZ] Abate narrowing conversion warning spam in flash_api.cpp (#153643)
for messages like ```/workspace/pytorch/aten/src/ATen/native/transformers/cuda/flash_attn/flash_api.cpp:1396:38: warning: narrowing conversion of ‘(char)(& q)->at::Tensor::<anonymous>.at::TensorBase::get_device()’ from ‘char’ to ‘c10::DeviceIndex’ {aka ‘signed ``` Pull Request resolved: #153643 Approved by: https://github.com/Skylion007
1 parent aac30ef commit e802b29

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

aten/src/ATen/native/transformers/cuda/flash_attn/flash_api.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ mha_fwd(const at::Tensor &q, // batch_size x seqlen_q x num_heads x head
479479

480480
// Otherwise the kernel will be launched from cuda:0 device
481481
// Cast to char to avoid compiler warning about narrowing
482-
at::cuda::CUDAGuard device_guard{(char)q.get_device()};
482+
at::cuda::CUDAGuard device_guard{static_cast<signed char>(q.get_device())};
483483

484484
auto opts = q.options();
485485

@@ -705,7 +705,7 @@ mha_varlen_fwd(const at::Tensor &q, // total_q x num_heads x head_size, total_q
705705

706706
// Otherwise the kernel will be launched from cuda:0 device
707707
// Cast to char to avoid compiler warning about narrowing
708-
at::cuda::CUDAGuard device_guard{(char)q.get_device()};
708+
at::cuda::CUDAGuard device_guard{static_cast<signed char>(q.get_device())};
709709

710710
auto opts = q.options();
711711

@@ -940,7 +940,7 @@ mha_bwd(const at::Tensor &dout, // batch_size x seqlen_q x num_heads, x head_si
940940

941941
// Otherwise the kernel will be launched from cuda:0 device
942942
// Cast to char to avoid compiler warning about narrowing
943-
at::cuda::CUDAGuard device_guard{(char)q.get_device()};
943+
at::cuda::CUDAGuard device_guard{static_cast<signed char>(q.get_device())};
944944

945945
auto opts = q.options();
946946
auto softmax_d = at::empty({batch_size, num_heads, seqlen_q_rounded}, opts.dtype(at::kFloat));
@@ -1163,7 +1163,7 @@ mha_varlen_bwd(const at::Tensor &dout, // total_q x num_heads, x head_size
11631163

11641164
// Otherwise the kernel will be launched from cuda:0 device
11651165
// Cast to char to avoid compiler warning about narrowing
1166-
at::cuda::CUDAGuard device_guard{(char)q.get_device()};
1166+
at::cuda::CUDAGuard device_guard{static_cast<signed char>(q.get_device())};
11671167

11681168
auto opts = q.options();
11691169
auto softmax_d = at::empty({num_heads, total_q + 128 * batch_size}, opts.dtype(at::kFloat));
@@ -1393,7 +1393,7 @@ mha_fwd_kvcache(at::Tensor &q, // batch_size x seqlen_q x num_he
13931393

13941394
// Otherwise the kernel will be launched from cuda:0 device
13951395
// Cast to char to avoid compiler warning about narrowing
1396-
at::cuda::CUDAGuard device_guard{(char)q.get_device()};
1396+
at::cuda::CUDAGuard device_guard{static_cast<signed char>(q.get_device())};
13971397

13981398
auto opts = q.options();
13991399

0 commit comments

Comments
 (0)
0