CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Dy2St] Optimize bool(Value)
error messages
#68078
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
Value(bool)
error messagesValue(bool)
error messages
python/paddle/pir/math_op_patch.py
Outdated
"bool(Value) is not supported in static graph mode. If you are using @to_static, you can try this:\n" | ||
"1. If you want to get the value of Value, you can switch to non-fullgraph mode by setting @to_static(full_graph=True).\n" | ||
"2. If you want to run it in full graph mode, you need use Value.astype(paddle.bool), and do not use bool(Value)." | ||
"bool(Tensor) is not supported in static graph mode. Because the value is not available during the grouping phase. \n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"bool(Tensor) is not supported in static graph mode. Because the value is not available during the grouping phase. \n" | |
"bool(Tensor) is not supported in static graph mode. Because the value is not available during the static mode. \n" |
python/paddle/pir/math_op_patch.py
Outdated
"2. If you are checking for Tensor values, then consider checking only at dynamic graphs, for example:\n" | ||
" Modify the following code\n" | ||
" >>> if x > 0:\n" | ||
' ... raise ValueError("x should be positive")\n' | ||
" to\n" | ||
" >>> if paddle.in_dynamic_mode() and x < 0:\n" | ||
' >>> raise ValueError("x should be positive")\n' | ||
"3. If you need to control the flow of execution based on the value of the Tensor, then you need to rewrite the code as a control flow, for example:\n" | ||
" Modify the following code\n" | ||
" >>> if x < y:\n" | ||
" ... y = y + 1\n" | ||
" ... else:\n" | ||
" ... y = y - 1\n" | ||
" to\n" | ||
" >>> pred = paddle.less_than(x=x, y=y, name=None)\n" | ||
" >>> y = paddle.static.nn.cond(pred, lambda: y + 1, lambda: y - 1)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2、3 和 1 不是并列关系,1 是问题展示,2、3 是解决方案,不能这样并列
而且,1 是对最开始描述的补充,应该和前面连在一起
python/paddle/pir/math_op_patch.py
Outdated
"1. If you want to get the value of Value, you can switch to non-fullgraph mode by setting @to_static(full_graph=True).\n" | ||
"2. If you want to run it in full graph mode, you need use Value.astype(paddle.bool), and do not use bool(Value)." | ||
"bool(Tensor) is not supported in static graph mode. Because the value is not available during the grouping phase. \n" | ||
"1. if you don't call bool(Tensor) explicitly, then it's usually triggered implicitly because of the control flow, for example:\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"1. if you don't call bool(Tensor) explicitly, then it's usually triggered implicitly because of the control flow, for example:\n" | |
"1. if you haven't call bool(Tensor) explicitly, it's usually triggered by the control flow implicitly, for example:\n" |
python/paddle/pir/math_op_patch.py
Outdated
"bool(Tensor) is not supported in static graph mode. Because the value is not available during the grouping phase. \n" | ||
"1. if you don't call bool(Tensor) explicitly, then it's usually triggered implicitly because of the control flow, for example:\n" | ||
" >>> if x > 0:\n" | ||
" ^ Tensor, x > 0 is also a Tensor, if x > 0 triggers bool(Tensor)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" ^ Tensor, x > 0 is also a Tensor, if x > 0 triggers bool(Tensor)\n" | |
" ^ `x` is Tensor, `x > 0` is also a Tensor, `if x > 0` triggers bool(Tensor)\n" |
python/paddle/pir/math_op_patch.py
Outdated
" ... y = y - 1\n" | ||
" to\n" | ||
" >>> pred = paddle.less_than(x=x, y=y, name=None)\n" | ||
" >>> y = paddle.static.nn.cond(pred, lambda: y + 1, lambda: y - 1)\n" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文档展示呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:补充链接
是这个?
Value(bool)
error messagesbool(Value)
error messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Category
Execute Infrastructure
PR Types
Improvements
Description
测试用例
新的报错信息: