Skip to content

Conversation

hzhangxyz
Copy link
Member

No description provided.

@hzhangxyz
Copy link
Member Author

@gausshj 你试试实现对 GrassmannTensor((), (), torch.tensor(2333)).reshape(((0, 1), (0, 1))).reshape(()) 这种操作的支持,代码上面可能有一定难度,你尽量试试。

@hzhangxyz hzhangxyz linked an issue Sep 2, 2025 that may be closed by this pull request
@hzhangxyz
Copy link
Member Author

@gausshj 你也思考一下,除了这个情况,是否已经覆盖所有的corner case了。

@gausshj
Copy link
Collaborator

gausshj commented Sep 2, 2025

@gausshj 你试试实现对 GrassmannTensor((), (), torch.tensor(2333)).reshape(((0, 1), (0, 1))).reshape(()) 这种操作的支持,代码上面可能有一定难度,你尽量试试。

好的,我试试。

@gausshj 你也思考一下,除了这个情况,是否已经覆盖所有的corner case了。

好的。

- Update the assertation statement for none edge reshape
- Fix bugs of reshape caused by new features
- Fix typo issues
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

❌ Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
grassmann_tensor/tensor.py 98.03% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

- Fix dimensional issues when reshape with none edges
- Add assertion test for none edges reshape
- Fix typo issues of reshape test

Signed-off-by: Gausshj <kylin_0@qq.com>
@gausshj gausshj marked this pull request as ready for review September 25, 2025 04:09
)
cursor_self = self.tensor.dim() - 1
else:
if cursor_plan != len(new_shape) and new_shape[cursor_plan] == -1:
Copy link
Member Author

Choose a reason for hiding this comment

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

为什么要加上这个判断 cursor_plan != len(new_shape) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

因为对于没有0维度的grassmann张量分解时,如果不加上这个判断会出现问题,cursor_plan这个变量可能会出现边界值。

# One dimension included, check if we can stop
if plan_total == self.tensor.shape[cursor_self]:
# new_shape block has been verified to be always tuple[int, int] before
if self.tensor.dim() == 0:
Copy link
Member Author

Choose a reason for hiding this comment

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

你在整个流程多次判断self.tensor.dim不如直接放在外面,这样时不时判断一下有点考验可读性。。。

Copy link
Member Author

Choose a reason for hiding this comment

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

如果你经过思考,确认确实只有前后dim=0的情况会触发问题,直接在最外面做判断吧。

Copy link
Collaborator

Choose a reason for hiding this comment

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

但是对于0维度张量的merge和split的逻辑基本是相同的,只是对这些特殊情况进行了处理,如果在最外层判断,可能得把相同的代码逻辑移植到外面,可能会使这个函数更长。

Copy link
Member Author

Choose a reason for hiding this comment

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

好,目前这个版本 2a2ab4e 可读性还行。

- Flatten if-else logic for readability

Signed-off-by: Gausshj <kylin_0@qq.com>
- Flatten if-else logic for readability

Signed-off-by: Gausshj <kylin_0@qq.com>
@hzhangxyz
Copy link
Member Author

看起来没啥大问题。我这两天再想想有没有啥情况漏的,你也想一想,如果没啥问题,周一合吧。

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.

reshape need more tests.

2 participants