Skip to content

Conversation

@Difers
Copy link
Contributor

@Difers Difers commented Jul 24, 2025

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

修复paddle.nn.functional.l1_loss底层Reduce Kernel int32溢出问题

Pcard-73145

  • 测例
import paddle input = paddle.rand([1, 2147483646], dtype="float16") //接近但小于int32边界 label = paddle.rand([1, 2147483646], dtype="float16") //接近但小于int32边界 l1_loss = paddle.nn.functional.l1_loss(input, label) print(l1_loss) 
  • 触发原因
    input.numel() 小于int32 边界 -> 走ReduceAnyKernel indextype int32分支 ->
    for (; input_idx + block_size < bound; input_idx += REDUCE_VEC_SIZE * stride)
    input_idx在循环最后一次可能int32溢出
@paddle-bot
Copy link

paddle-bot bot commented Jul 24, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@Difers Difers changed the title [PHI] Fix int32 overflow for l1_loss [BIG tensor]Fix int32 overflow for l1_loss Jul 24, 2025
@lshpku lshpku merged commit 0a94741 into PaddlePaddle:develop Jul 29, 2025
55 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants