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

Add cat_union #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add cat_union #130

wants to merge 2 commits into from

Conversation

jbjeong
Copy link

@jbjeong jbjeong commented Apr 23, 2020

Hello,

I made a simple function to concatenate the tensors which have different sparsity.
This can be used in UNet based auto-encoder, where generated tensors and skipped tensors have different sparsity.

Thanks

@chrischoy
Copy link
Contributor

Thanks for your contribution.

However, this function requires creating two existing coords map A.C, B.C.
Could you use get_union_map on https://github.com/StanfordVL/MinkowskiEngine/blob/master/MinkowskiEngine/MinkowskiCoords.py#L314 to remove the unnecessary coordinate creation?

assert cm == B.coords_man, "different coords_man"
assert A.tensor_stride == B.tensor_stride, "different tensor_stride"

zeros_cat_with_A = torch.zeros([A.F.shape[0], B.F.shape[1]]).to(A.device)
Copy link
Contributor

Choose a reason for hiding this comment

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

dtype specification required.

Copy link
Contributor

Choose a reason for hiding this comment

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

zeros(shape, dtype=A.device)

feats_A = torch.cat([A.F, zeros_cat_with_A], dim=1)
feats_B = torch.cat([zeros_cat_with_B, B.F], dim=1)

new_A = SparseTensor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary coordinate creation. This essentially force create the same existing coords hash map.

Try using get_union_map. https://github.com/StanfordVL/MinkowskiEngine/blob/ded4c0c42ae50482f44f909a37fef16af16c36ec/MinkowskiEngine/MinkowskiCoords.py#L314

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.

2 participants