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

转换规则 No.240-242. #119

Merged
merged 4 commits into from
Jun 26, 2023
Merged

转换规则 No.240-242. #119

merged 4 commits into from
Jun 26, 2023

Conversation

txyugood
Copy link
Contributor

PR Docs

PaddlePaddle/docs#5951
from_dlpack与to_dlpack的映射文档已存在。

PR APIs

torch.utils.data.random_split
torch.utils.dlpack.from_dlpack
torch.utils.dlpack.to_dlpack

#112

@paddle-bot
Copy link

paddle-bot bot commented Jun 23, 2023

Thanks for your contribution!

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Jun 23, 2023
class RandomSplitMatcher(BaseMatcher):
def generate_code(self, kwargs):
if "lengths" in kwargs:
API_TEMPLATE = textwrap.dedent(
Copy link
Contributor

Choose a reason for hiding this comment

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

这个lengths参数能绕过吗,把浮点数转化为int类型

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里不判断,然后生成的代码里判断lengths是浮点就转换成int类型的意思吗?

Copy link
Contributor

Choose a reason for hiding this comment

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

对,应该能实现

@txyugood
Copy link
Contributor Author

参考torch版本的random_split对lengths的处理修改了一下。

def generate_code(self, kwargs):
API_TEMPLATE = textwrap.dedent(
"""
import math
Copy link
Contributor

@ROckDog22 ROckDog22 Jun 26, 2023

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了

Copy link
Contributor Author

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(
Copy link
Contributor

Choose a reason for hiding this comment

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

可以添加一些length是int类型的,以及带有参数名称的单测,这样是不是测的全一些

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ROckDog22
Copy link
Contributor

LGTM

@ROckDog22 ROckDog22 merged commit 8863e7b into PaddlePaddle:master Jun 26, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jun 26, 2023
@luotao1
Copy link
Collaborator

luotao1 commented Jun 26, 2023

hi, @txyugood

  • 非常感谢你对飞桨框架的贡献,我们正在运营一个PFCC组织,会通过定期分享技术知识与发布开发者主导任务的形式持续为飞桨框架做贡献,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR status: accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants