Skip to content
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

translate bytecode ops #36

Merged
merged 4 commits into from
Apr 10, 2023
Merged

Conversation

Asthestarsfalll
Copy link
Collaborator

No description provided.

@Asthestarsfalll Asthestarsfalll changed the title translate compare_op bytecode ops translate bytecode ops Apr 6, 2023
@Asthestarsfalll Asthestarsfalll mentioned this pull request Apr 6, 2023
16 tasks
Copy link
Collaborator

@gglin001 gglin001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, 👍

@gglin001 gglin001 requested a review from jzhang533 April 7, 2023 04:05
@Asthestarsfalll
Copy link
Collaborator Author

逻辑相关的op转换还有点问题,在排查中

@Asthestarsfalll
Copy link
Collaborator Author

2023-04-08_16-29

逻辑相关(|,&,^等)操作会进行静态图判断,这种含分支的情况似乎不太好处理

@SigureMo
Copy link
Collaborator

SigureMo commented Apr 9, 2023

逻辑相关(|,&,^等)操作会进行静态图判断,这种含分支的情况似乎不太好处理

是说位操作吧,由于目前所有 frame 的 code 都是原样执行,所以只要有 frame 的函数都会进入 Translator

对于 Paddle 的 EagerTensor 来说,+- 等 operator 是直接在 C++ 端实现的( https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/pybind/eager_math_op_patch.cc#L191 ),但 &| 不是的,他们是在 Python 端定义的函数,之后直接 patch 上的( https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/dygraph/math_op_patch.py#L516 ),所以他们一定有 frame,只要执行他们,也一定会进入这个 eval frame,因此目前 code 原样返回的情况想要支持这些 operator 可能有些麻烦

目前的话,我觉得把 C++ 端实现的 magic funcs 支持就可以了( https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/dygraph/math_op_patch.py#L458

@Asthestarsfalll
Copy link
Collaborator Author

is << >>等也存在问题,主要是因为LOAD_CONST,如

b = a << 2

此处2不会被加入stack中,会导致node的参数错误,或是stack为空报错
如果考虑加入的话,某些情况不太好处理:

print('ababa')

Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
我们先合入吧。
接下来咱们再整理一下下后续的TODO,另外再提PR。

@jzhang533 jzhang533 merged commit 82d8d99 into PFCCLab:main Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants