-
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.358/361 #256
转换规则 No.358/361 #256
Conversation
Thanks for your contribution! |
paconvert/api_matcher.py
Outdated
def generate_code(self, kwargs): | ||
out_v = kwargs.pop("out") if "out" in kwargs else None | ||
check_errors_v = ( | ||
kwargs.pop("check_errors") if "check_errors" in kwargs else None |
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.
已取消 check_errors
x = torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]], dtype=torch.float64) | ||
out = (torch.tensor([], dtype=torch.float64), torch.tensor([], dtype=torch.int), torch.tensor([], dtype=torch.int)) | ||
LU, pivots, info = torch.linalg.lu_factor_ex(A=x, pivot=True, check_errors=True, out=out) | ||
info = info.item() |
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.
这个info是有一些输出的不同吗?比如paddle是Tensor,torch是python scalar?
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.
shape不一样,paddle是[1],torch是整数值
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.
shape不一样,paddle是[1],torch是整数值
这个地方那也需要转写一下,在转写里第三个参数里改成 info.item()
paconvert/api_matcher.py
Outdated
@@ -4061,6 +4061,60 @@ def generate_code(self, kwargs): | |||
return code | |||
|
|||
|
|||
class LinalgLufactorMatcher(BaseMatcher): |
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.
这个应该可以复用 TupleAssignMatcher
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.
已修改
paconvert/api_matcher.py
Outdated
return code | ||
|
||
|
||
class LinalgLufactorexMatcher(BaseMatcher): |
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.
可以改成一个通用的 TripleAssignMatcher
,配置:
"check_errors": ""
这样代码能最大化的保持复用,方便日后维护更新
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.
已修改
还需要处理下冲突 |
已修改 |
x = torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]], dtype=torch.float64) | ||
out = (torch.tensor([], dtype=torch.float64), torch.tensor([], dtype=torch.int), torch.tensor([], dtype=torch.int)) | ||
LU, pivots, info = torch.linalg.lu_factor_ex(A=x, pivot=True, check_errors=True, out=out) | ||
info = info.item() |
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.
shape不一样,paddle是[1],torch是整数值
这个地方那也需要转写一下,在转写里第三个参数里改成 info.item()
@co63oc 我先合入了,这个 |
PR Docs
#112
358 torch.linalg.lu_factor
361 torch.linalg.lu_factor_ex 返回info的shape不一致,修改为info=info.item()比较, check_errors参数映射为增加assert验证
映射文档 PaddlePaddle/docs#6139
PR APIs