[0-size Tensor Job2 No.60] Add 0-size Tensor support for paddle.nn.functional.instance_norm [fluid_ops]#73854
Conversation
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (44.82%) 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 #73854 +/- ##
==========================================
Coverage ? 44.82%
==========================================
Files ? 4
Lines ? 29
Branches ? 0
==========================================
Hits ? 13
Misses ? 16
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bf3b13d to
35db413
Compare
|
@DanielSun11 CI已完成需要review |
|
/re-run all-failed |
|
代码改动较大,请 @wanghuancoder review一下 |
wanghuancoder
left a comment
There was a problem hiding this comment.
请 @luotao1 协调云飞帮忙看看
| args : (Tensor x, Tensor scale, Tensor bias, Tensor saved_mean, Tensor saved_variance, Tensor y_grad, float epsilon=1e-5) | ||
| output : Tensor(x_grad), Tensor(scale_grad), Tensor(bias_grad) | ||
| infer_meta : | ||
| func : InstanceNormGradInferMeta | ||
| spmd_rule : InstanceNormGradInferSpmd | ||
| kernel : | ||
| func : instance_norm_grad | ||
| data_type : x | ||
| optional : scale | ||
| optional : scale, bias | ||
| backward : instance_norm_double_grad | ||
| composite: instance_norm_grad(x, scale, saved_mean, saved_variance, y_grad, epsilon, x_grad, scale_grad, bias_grad) | ||
| composite: instance_norm_grad(x, scale, bias, saved_mean, saved_variance, y_grad, epsilon, x_grad, scale_grad, bias_grad) |
There was a problem hiding this comment.
这里有几个问题需要云飞评估:
- 修改反向签名是否涉及不兼容升级?
- 如果只是InferMeta用,好像有办法不修改函数签名,在kernel->func中标记需要传给Kernel的参数有哪些,可以参考lp_pool2d_grad的param。也需要云飞确认,这种用法用的比较少
- 这个bias如果只是InferMeta用,又是optional的是否可以标记为no need buffer?也需要云飞确认
There was a problem hiding this comment.
2. lp_pool2d_grad
和lp_pool2d_grad不同的是,这里同时使用了composite,使用func传参数,composite中会报错
There was a problem hiding this comment.
改反向一般不影响推理兼容性
配置no need buffer这里不太确定有没有问题,可能需要实际测试下
There was a problem hiding this comment.
已修改 增加 no_need_buffer : bias
| template <typename T> | ||
| void instance_norm_grad(const Tensor& x, | ||
| const paddle::optional<Tensor>& scale, | ||
| const paddle::optional<Tensor>& bias UNUSED, |
There was a problem hiding this comment.
不增加bias参数,composite这部分报错
| args : (Tensor x, Tensor scale, Tensor bias, Tensor saved_mean, Tensor saved_variance, Tensor y_grad, float epsilon=1e-5) | ||
| output : Tensor(x_grad), Tensor(scale_grad), Tensor(bias_grad) | ||
| infer_meta : | ||
| func : InstanceNormGradInferMeta | ||
| spmd_rule : InstanceNormGradInferSpmd | ||
| kernel : | ||
| func : instance_norm_grad | ||
| data_type : x | ||
| optional : scale | ||
| optional : scale, bias | ||
| backward : instance_norm_double_grad | ||
| composite: instance_norm_grad(x, scale, saved_mean, saved_variance, y_grad, epsilon, x_grad, scale_grad, bias_grad) | ||
| composite: instance_norm_grad(x, scale, bias, saved_mean, saved_variance, y_grad, epsilon, x_grad, scale_grad, bias_grad) |
There was a problem hiding this comment.
改反向一般不影响推理兼容性
配置no need buffer这里不太确定有没有问题,可能需要实际测试下
|
/re-run all-failed |
1 similar comment
|
/re-run all-failed |
|
@zyfncg 已增加no_need_buffer,CI已完成 |
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
[0-size Tensor Job2 No.60] Add 0-size Tensor support for paddle.nn.functional.instance_norm [fluid_ops]
InstanceNormInferMeta 取消维度为0判断
符号推导没有对应代码
Paddle/paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.cc
Line 2729 in 1b1ad5a
InstanceNormGradInferMeta 修改scale、bias中维度设置为0部分,设置为scale、bias对应维度,增加bias参数
修改 backward.yaml配置文件,kernel增加bias参数, 使用到 composite 配置,修改paddle/fluid/prim/api/composite_backward/composite_backward_api.h文件增加bias参数
修改kernel前向,反向,填充为0
增加单测
torch 测试反向填充
PaddleAPITest测试通过
