-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Python array API standard] Support Tensor.mT in eager/static mode #68833
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提交成功,感谢你对开源项目的贡献! |
if len(self.shape) == 1: | ||
return self | ||
perm = list(range(len(self.shape))) | ||
perm[-1], perm[-2] = perm[-2], perm[-1] |
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 场景下的正确性,包括 shape[-1] = 0
、shape[-2] = 0
、shape[-1] = 0
且 shape[-2] = 0
的情况
perm = list(range(len(self.meta.shape))) | ||
perm[-1], perm[-2] = perm[-2], perm[-1] | ||
|
||
perm_var = ListVariable(perm, self.graph, tracker=ConstTracker(perm)) |
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.
perm_var = ListVariable(perm, self.graph, tracker=ConstTracker(perm)) | |
perm_var = ListVariable(perm, self.graph, tracker=DummyTracker(self)) |
perm[-1], perm[-2] = perm[-2], perm[-1] | ||
|
||
perm_var = ListVariable(perm, self.graph, tracker=ConstTracker(perm)) | ||
assert perm_var is not 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.
这行应该是没有必要的,因为上面的构造函数结果一定是 ListVariable
test/sot/test_18_tensor_method.py
Outdated
@@ -90,6 +94,12 @@ def test_middle_tensor_name(self): | |||
y = paddle.rand([42, 24]) | |||
self.assert_results(middle_tensor_name, x, y) | |||
|
|||
def test_tensor_method_property_mT(self): | |||
x = paddle.rand([42, 24], dtype='float64') | |||
y = paddle.rand([42, 24], dtype='float32') |
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.
这个换一个更高维的测一下?只改 dtype 好像差别不大
c3bee6a
to
fe1547f
Compare
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
User Experience
PR Types
New features
Description
Pcard-75624
根据 https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.mT.html#mt,为动静态图的张量添加
.mT
接口以获取高维张量的矩阵转置