Skip to content

Conversation

@WintersMontagne10335
Copy link
Contributor

PR Category

Operator Mechanism

PR Types

New features

Description

paddle.nn.MaxPool2D兼容性增强

@paddle-bot
Copy link

paddle-bot bot commented Dec 1, 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-commenter commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 80.25210% with 94 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@fdac870). Learn more about missing BASE report.

Files with missing lines Patch % Lines
.../interface/infer_symbolic_shape/unary_infer_sym.cc 0.00% 82 Missing ⚠️
python/paddle/nn/functional/pooling.py 70.00% 6 Missing ⚠️
...terface/infer_symbolic_shape/backward_infer_sym.cc 0.00% 3 Missing ⚠️
paddle/phi/kernels/impl/pool_kernel_impl.h 93.75% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (80.25%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #76714   +/-   ##
==========================================
  Coverage           ?   80.25%           
==========================================
  Files              ?       11           
  Lines              ?      476           
  Branches           ?        0           
==========================================
  Hits               ?      382           
  Misses             ?       94           
  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.

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

@zhwesky2010
Copy link
Contributor

#76457 这个PR还需要吗

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看一下覆盖率CI,确保增加的逻辑都能测试到,同时在PaConvert里也加一些dilation的测试,确保与torch结果也是对齐的。

output = _C_ops.max_pool2d_with_index(
x, kernel_size, stride, padding, False, False, ceil_mode
)
if dilation_greater_than_one:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能否直接在原来的max_pool2d_with_index上加参数dilation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个可以,最新的commit实现了

op_type = 'max_pool2d_with_index' if return_mask else "pool2d"
if return_mask:
if dilation_greater_than_one:
op_type = 'max_pool2d_with_dilations_and_index'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能否直接在原来op上加参数。这样op会太多了比较复杂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以在 max_pool2d_with_index 上加参数,但是没有办法在 pool_2d 上加参数。

backward : max_grad
interfaces : paddle::dialect::InferSymbolicShapeInterface, paddle::dialect::LayoutTransformationInterface

- op : max_pool2d_with_dilations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在op有点太多了,只是多一个兼容的参数,还是在原来上改吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原先的PR是那样做的,会有一大堆兼容性问题,很难在pool_2d上加参数。

return true;
}

bool MaxPool2dWithDilationsGradOpInferSymbolicShape(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infer_sym这些需要开CINN模式来测

Copy link
Contributor Author

@WintersMontagne10335 WintersMontagne10335 Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/PaddlePaddle/Paddle/blob/develop/test/legacy_test/op_test.py#L2941 ,测这个需要 check_symbol_infer(默认值为True)、check_pir 都为True,check_pir 已经设置为True。

@WintersMontagne10335
Copy link
Contributor Author

#76457 这个PR还需要吗

不需要了

@WintersMontagne10335
Copy link
Contributor Author

@zhwesky2010 老师有时间 review 一下吧,ci 基本通过了。
approval 和 static-check 是因为 api 变动,需要对应的研发老师审核。
coverage 已经确定了问题,本地打 log 能覆盖到,正在 issue 里和那边的老师沟通。

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed


# use 2d to implement 1d should expand padding in advance.
padding = _expand_low_nd_padding(padding)
dilation = convert_to_list(1, 2, 'pool_dilation')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是一个写死的dilation吗?

Copy link
Contributor Author

@WintersMontagne10335 WintersMontagne10335 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是 max_pool1d,暂时还不支持 dilation,因为它调用了cpp层的 max_pool2d_with_index,所以这里给一个写死的值做兼容

"data_format": data_format,
},
)
if return_mask:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return_mask为何影响到dilation是否传入

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个也是 max_pool1d,也是为了兼容cpp层的修改

)

dilation = convert_to_list(dilation, 2, 'pool_dilation')
dilation_greater_than_one = dilation[0] > 1 or dilation[1] > 1
Copy link
Contributor

@zhwesky2010 zhwesky2010 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个>1还得额外搞个分支吗,不能传入到kernel里再判断吗。

这样写,静态图下也根本跑不了吧。静态图组网时都没有数值。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

传入到kernel里再判断:done

)
return output if return_mask else output[0]
else:
if dilation_greater_than_one:
Copy link
Contributor

@zhwesky2010 zhwesky2010 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果help这个分支有问题,可以不修改。这个功能加到dynamic_or_pir下。

Copy link
Contributor

@zhwesky2010 zhwesky2010 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python尽量不要去加太多分支和逻辑。pool_2d的兼容性问题是什么?是在老IR分支吗,老IR可以不维护

Copy link
Contributor Author

@WintersMontagne10335 WintersMontagne10335 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dilation_greater_than_one 不需要了,最新 commit 将相关分支下沉到 cpp 了

@WintersMontagne10335
Copy link
Contributor Author

test_layers 报错了,我再看看

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改我感觉是可以的,python层没有太多trick了。
但是目前dilation为何只给max_pool2d来使用,这个题目本意是max_pool1/2/3中缺dilation功能的都支持

infoflow 2025-12-17 16-59-51

)
return output if return_mask else output[0]
else:
return _C_ops.pool2d(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是说直接修改pool2d会引起很多兼容性问题对吧,所以改名为一个新op:max_pool2d_with_dilations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avg 等等其他算子也依赖 pool2d,对于它们来说,dilation是冗余的

@WintersMontagne10335
Copy link
Contributor Author

这样改我感觉是可以的,python层没有太多trick了。 但是目前dilation为何只给max_pool2d来使用,这个题目本意是max_pool1/2/3中缺dilation功能的都支持

infoflow 2025-12-17 16-59-51

这个是黑客松的赛题之一,赛题要求是给 max_pool2d 新增参数 dilation。
老师可以联系一下涛姐,让她在黑客松再发一下 1d 和 3d 任务~
说实话,这个工作量已经够大了,快一个月了,还要再做 1d 和 3d,我真顶不住了哈哈。

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

5 similar comments
@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

@SigureMo
Copy link
Member

SigureMo commented Dec 18, 2025

一条流水线(workflow,比如 CI、CI build)里有任何一个 job 仍在运行的话,rerun 是没效果的,别发了,我这邮件一直响 😂

@SigureMo
Copy link
Member

目前这个 rerun comment 是写在哪里的文档里了?需要更新下文档,另外 rerun 失败需要通过 comment 来告知开发者

cc @swgu98 @ooooo-create

@WintersMontagne10335
Copy link
Contributor Author

一条流水线(workflow,比如 CI、CI build)里有任何一个 job 仍在运行的话,rerun 是没效果的,别发了,我这邮件一直响 😂

我的,不好意思

@SigureMo
Copy link
Member

我的,不好意思

文档的问题,问下 /re-run all-failed 是在哪个外部文档看到的,我不记得哪里有写过这个,我找时间更新下,如果没有的话我找时间在贡献指南看看是不是有相关内容更新下

@ooooo-create
Copy link
Contributor

目前这个 rerun comment 是写在哪里的文档里了?需要更新下文档,另外 rerun 失败需要通过 comment 来告知开发者

cc @swgu98 @ooooo-create

这个目前确实是缺少外部文档记录,需要添加一下,之前应该是别人告诉才知道

@WintersMontagne10335
Copy link
Contributor Author

一条流水线(workflow,比如 CI、CI build)里有任何一个 job 仍在运行的话,rerun 是没效果的,别发了,我这邮件一直响 😂

只要发这个指令就会响吗,我等全部都跑完再re-run可以不

@WintersMontagne10335
Copy link
Contributor Author

/re-run all-failed

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

Labels

API Compatibility contributor External developers HappyOpenSource 快乐开源活动issue与PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants