Skip to content

Conversation

@zhengshengning
Copy link
Contributor

@zhengshengning zhengshengning commented Oct 30, 2025

PR Category

Operator Mechanism

PR Types

New features

Description

修改内容:

  1. 去掉了原来 cudnn 的实现方式(通过跟相关负责人沟通得知,原来的实现是临时方案,且无法与torch精度对齐);
  2. 分别对4D和5D手写了对应的cuda kernel实现;

前向传播

  1. 生成基础网格:

    • 4D: 为每个(H, W)位置生成归一化坐标(x, y, 1)
    • 5D: 为每个(D, H, W)位置生成归一化坐标(x, y, z, 1)
  2. 仿射变换:

    • 4D: [N, H×W, 3] × [N, 3, 2] = [N, H×W, 2]
    • 5D: [N, D×H×W, 4] × [N, 4, 3] = [N, D×H×W, 3]

反向传播

  1. 梯度计算:
    • 4D: [N, 3, H×W] × [N, H×W, 2] = [N, 3, 2] → 转置为 [N, 2, 3]
    • 5D: [N, 4, D×H×W] × [N, D×H×W, 3] = [N, 4, 3] → 转置为 [N, 3, 4]

两者遵循相同的计算模式:生成基础网格 → 应用仿射变换 → 输出变换后的网格坐标。

测试结果:

  1. 测试集的 paddle.nn.functional.affine_grid 的4D case 全部对齐(10个);
  2. 新增 10 个 5D的测试case全部通过(10个);

devPR:#76066

@paddle-bot
Copy link

paddle-bot bot commented Oct 30, 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.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (fleety_12@7320f14). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@
##             fleety_12    #76128   +/-   ##
=============================================
  Coverage             ?   100.00%           
=============================================
  Files                ?         1           
  Lines                ?         1           
  Branches             ?         0           
=============================================
  Hits                 ?         1           
  Misses               ?         0           
  Partials             ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants