-
Notifications
You must be signed in to change notification settings - Fork 55
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
转换规则 No.240-242. #119
转换规则 No.240-242. #119
Conversation
Thanks for your contribution! |
paconvert/api_matcher.py
Outdated
class RandomSplitMatcher(BaseMatcher): | ||
def generate_code(self, kwargs): | ||
if "lengths" in kwargs: | ||
API_TEMPLATE = textwrap.dedent( |
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.
这个lengths参数能绕过吗,把浮点数转化为int类型
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.
这里不判断,然后生成的代码里判断lengths是浮点就转换成int类型的意思吗?
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.
对,应该能实现
参考torch版本的random_split对lengths的处理修改了一下。 |
paconvert/api_matcher.py
Outdated
def generate_code(self, kwargs): | ||
API_TEMPLATE = textwrap.dedent( | ||
""" | ||
import math |
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.
转换的前提是已经确保torch代码是正确的,这里因为torch对应的API已经验证过了,可不可以只判断length是不是浮点数,这样的话就不需要再import math了
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.
Done.
|
||
|
||
def test_case_1(): | ||
pytorch_code = textwrap.dedent( |
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.
可以添加一些length是int类型的,以及带有参数名称的单测,这样是不是测的全一些
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.
Done.
LGTM |
hi, @txyugood
|
PR Docs
PaddlePaddle/docs#5951
from_dlpack与to_dlpack的映射文档已存在。
PR APIs
#112