CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[SOT][3.13] support CONVERT_VALUE
and FORMAT_WITH_SPEC
opcode in python3.13
#69401
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提交成功,感谢你对开源项目的贡献! |
python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py
Outdated
Show resolved
Hide resolved
test/sot/test_22_convert_string.py
Outdated
|
||
def foo(x: paddle.Tensor): | ||
float_num = 3.1415 | ||
float_string = f"{float_num:.2f}" |
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.
这个测试 case 是否可以直接添加到 test_09_f_string
里?
测试名称可以改一下,不用 foo
,这是最初设计单测时候随便起的
python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py
Outdated
Show resolved
Hide resolved
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 suggestion.
) | ||
if isinstance(value, ConstantVariable): | ||
result = value.get_py_value() | ||
result = getattr(result, convert_fn)(result) |
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.
The method retrieved using getattr
should be called without passing result
as an argument. It should be result = getattr(result, convert_fn)()
.
result = getattr(result, convert_fn)(result) | |
result = getattr(result, convert_fn)() |
Copilot uses AI. Check for mistakes.
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.
这个看起来挺合理,@GoldenStain 看看这样是否正确?
之前代码也是这样写的,有点怀疑之前是怎么跑的,需要确认下单测是否能跑到这个分支,以及 result
是什么,正常字符串应该会挂的
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.
目前的测试函数
def fstring_with_spec(x: paddle.Tensor):
float_num = 3.1415
float_string = f"{float_num:.2f}"
z = assert_true(float_string == "3.14")
x = x + 1
return x
只能触发FORMAT_WITH_SPEC
还不能触发CONVERT_VALUE
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.
确实不能传入参数
File "/workspace/Paddle/test/sot/test_09_f_string.py", line 36, in fstring_with_convert_test
formatted_string = f"{obj!r}"
TypeError: expected 0 arguments, got 1
…ase about CONVERT_VALUE
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
Performance Optimization
PR Types
Others
Description
支持了字节码
CONVERT_VALUE
和FORMAT_WITH_SPEC
,为test_09_f_string.py
添加了对FORMAT_WITH_SPEC
和CONVERT_VALUE
的测试;完善了原先字节码
FORMAT_VALUE
的format转换。