-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
masked_fill_
對int64處理異常,塞入paddle.iinfo(paddle.int64).max會被當作min
#64365
Comments
@AndSonder 这个问题能否辛苦看下呢? OP来源:#57355 |
@zyfncg 看起来是 full op 里面的 bug,如下代码会产生溢出 >>> paddle.full([], 2**63-1, paddle.int64)
Tensor(shape=[], dtype=int64, place=Place(gpu:0), stop_gradient=True,
-9223372036854775808) |
@anderson101866 您可以通过如下代码实现想要的功能
|
👍 这样的话paddle.full是否可以替换为to_tensor呢? |
可以替换,但是是不是还是修复 full 的这个 bug 会好一些,要不还有可能有其他 api 有类似的没发现的越界问题 |
類似的問題我也有碰到 也很像overflow的問題 import paddle; print(paddle.__version__) #2.6.0
x = paddle.to_tensor([[0, 0],
[-2**63, 0]], dtype=paddle.int64)
print(x)
x == 2**63-1 # __eq__
#Tensor(shape=[2, 2], dtype=bool, place=Place(gpu:0), stop_gradient=True,
# [[False, False],
# [True , False]]) 一樣是max會被當成min |
这个应该是数值溢出导致的,也有可能是类似的原因导致的 |
验证了下,确实是这里导致的 |
还有一个问题就是在静态图模式下这里的value也只能用float类型表示,动态图的类型即使转为int64,在动转静后还是会遇到这里精度溢出的问题 |
这个问题,早期的版本修复过,会使用 Paddle/paddle/fluid/operators/fill_constant_op.h Lines 39 to 70 in 0ee230a
Paddle/python/paddle/fluid/layers/tensor.py Lines 716 to 722 in 0ee230a
|
與百度溝通後,Kai Wang表示現在這個工作沒有排期,NV目前沒有blocking。 附帶,對 比如相等 import paddle; print(paddle.__version__) #2.6.0
x = paddle.to_tensor([[0, 0],
[-2**63, 0]], dtype=paddle.int64)
print(x)
x == 2**63-1 # __eq__
#Tensor(shape=[2, 2], dtype=bool, place=Place(gpu:0), stop_gradient=True,
# [[False, False],
# [True , False]]) |
bug描述 Describe the Bug
如下單純的script,帶入int64最大值時,會變成最小值
其他补充信息 Additional Supplementary Information
No response
The text was updated successfully, but these errors were encountered: