【Hackathon 8th No.12】为 paddle.clip 进行功能增强 #69269
【Hackathon 8th No.12】为 paddle.clip 进行功能增强 #69269a162837 wants to merge 75 commits intoPaddlePaddle:developfrom
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
|
为什么我两个的ci都没有跑的? @luotao1 |
|
@sunzhongkai588 你好,请问为什么我的ci都不跑的,已经一天了 |
0d8a99c to
81b1c78
Compare
|
📢:请尽快完善锁定的PR,并确保在2025年1月10日(不再延期)前完成合入。逾期未合入PR将无法获得奖金发放。 |
| return _C_ops.log10_(x) | ||
|
|
||
|
|
||
| def is_clip_tensor(value): |
python/paddle/tensor/math.py
Outdated
| return False | ||
|
|
||
|
|
||
| def get_clip_tensor_shape(value1, value2, value3): |
| min = min_ if min is None else min | ||
| max = max_ if max is None else max | ||
|
|
||
| if is_clip_tensor(min) or is_clip_tensor(max): |
There was a problem hiding this comment.
if paddle.is_tensor(min) and paddle.is_tensor(max):
x_bcast, min_bcast, max_bcast = paddle.broadcast_tensors([x, min, max])
其他的逻辑与之前保持不变,这里就不用封装其他函数了
python/paddle/tensor/math.py
Outdated
| ) | ||
| return output | ||
| if in_dynamic_or_pir_mode(): | ||
| if isinstance(min, Variable): |
There was a problem hiding this comment.
if paddle.is_tensor(min)
python/paddle/tensor/math.py
Outdated
| return output | ||
| if in_dynamic_or_pir_mode(): | ||
| if isinstance(min, Variable): | ||
| min = min.item(0) |
There was a problem hiding this comment.
if paddle.is_tensor(max)
第3884、3885行应该不需要了吧
python/paddle/tensor/math.py
Outdated
| max.stop_gradient = True | ||
| return _C_ops.clip_tensor_(x, min, max) | ||
| else: | ||
| return _C_ops.clip_(x, min, max) |
There was a problem hiding this comment.
在这个else分支下增加一个逻辑:
if paddle.is_tensor(min):
min = min.item()
if paddle.is_tensor(max):
max = max.item()
python/paddle/tensor/math.py
Outdated
| min = fmin if min is None else min | ||
| max = fmax if max is None else max | ||
|
|
||
| if in_dynamic_mode(): |
There was a problem hiding this comment.
这个if in_dynamic_mode(): 可以去掉了,这个API只能在动态图下跑
python/paddle/tensor/math.py
Outdated
|
|
||
| if in_dynamic_mode(): | ||
| return _C_ops.clip_(x, min, max) | ||
| if is_clip_tensor(min) or is_clip_tensor(max): |
There was a problem hiding this comment.
同上
if paddle.is_tensor(min) and paddle.is_tensor(max):
....
另外这个分支下面做broadcase时,需要判断一点:x.shape==broadcast_shape(broadcast_shape(min.shape, max.shape), x.shape)
因为只能min或max向x广播,x不能向min或max广播
| 'instance_norm', | ||
| 'affine_grid', | ||
| 'clip', | ||
| 'clip_tensor', |
There was a problem hiding this comment.
这个为何要加到白名单?这个不是计算类OP,按道理误差不应该很大
|
@luotao1 @sunzhongkai588 您好,這個能夠放到第8期嗎,我看那個lu_solve的可以 |
PR Category
Inference
PR Types
Others
Description
【Hackathon 7th No.28】为 paddle.clip 进行功能增强
PaddlePaddle/docs#6924