Skip to content

Conversation

@heitorschueroff
Copy link
Contributor

@heitorschueroff heitorschueroff commented Aug 4, 2020

Stack from ghstack:

Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

Differential Revision: D23030301

heitorschueroff added a commit that referenced this pull request Aug 4, 2020
ghstack-source-id: 7b176ea
Pull Request resolved: #42563
@dr-ci
Copy link

dr-ci bot commented Aug 4, 2020

💊 CI failures summary and remediations

As of commit 011eb2b (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 47 times.

@glaringlee glaringlee requested review from albanD and zou3519 August 4, 2020 21:29
Copy link
Contributor

@glaringlee glaringlee left a comment

Choose a reason for hiding this comment

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

Other than reviews from @zou3519
Two things want to confirm here @zou3519 @heitorschueroff :

  1. This is not really a bc breaking change, but it breaks bc CI test, I think this is one time breaking after checking the check_backward_compatibility.py, but need to confirm.
  2. I think unflatten should be added into _overrides.py here like flatten:
    torch.flatten: lambda input, start_dim=0, end_dim=-1: -1,

@zou3519
Copy link
Contributor

zou3519 commented Aug 5, 2020

Aug 04 23:06:48 Broken ops: [
Aug 04 23:06:48 aten::unflatten.Dimname(Tensor self, str dim, int[] sizes, str[] names) -> (Tensor)
Aug 04 23:06:48 aten::unflatten.int(Tensor self, int dim, int[] sizes, str[] names) -> (Tensor)
Aug 04 23:06:48 ]

I'm pretty confident no one has serialized the above operators because they literally don't work in TorchScript (we've banned named tensors in TorchScript). So I wouldn't worry about the BC-breakage.

I remember there was a way to "approve" a change to the backwards compatibility test so the PR doesn't break anything when it gets merged. cc @houseroad -- how does one do that again?

@glaringlee
Copy link
Contributor

glaringlee commented Aug 5, 2020

Other than reviews from @zou3519
Two things want to confirm here @zou3519 @heitorschueroff :

  1. This is not really a bc breaking change, but it breaks bc CI test, I think this is one time breaking after checking the check_backward_compatibility.py, but need to confirm.
  2. I think unflatten should be added into _overrides.py here like flatten:
    torch.flatten: lambda input, start_dim=0, end_dim=-1: -1,

Update: No need to add unflatten into _overrides.py, since we don't support torch.unflatten.

Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

[ghstack-poisoned]
@glaringlee
Copy link
Contributor

glaringlee commented Aug 6, 2020

Aug 04 23:06:48 Broken ops: [
Aug 04 23:06:48 aten::unflatten.Dimname(Tensor self, str dim, int[] sizes, str[] names) -> (Tensor)
Aug 04 23:06:48 aten::unflatten.int(Tensor self, int dim, int[] sizes, str[] names) -> (Tensor)
Aug 04 23:06:48 ]

I'm pretty confident no one has serialized the above operators because they literally don't work in TorchScript (we've banned named tensors in TorchScript). So I wouldn't worry about the BC-breakage.

I remember there was a way to "approve" a change to the backwards compatibility test so the PR doesn't break anything when it gets merged. cc @houseroad -- how does one do that again?

@heitorschueroff Per @houseroad , please add unflatten function here https://fburl.com/lsb7ah1y
The date should be 1 week after expected landing time.

Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

[ghstack-poisoned]
@glaringlee
Copy link
Contributor

@heitorschueroff
All looks good to me now. One more thing, please fix flake8-py3 lint error

Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

[ghstack-poisoned]
Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

[ghstack-poisoned]
Copy link
Contributor

@glaringlee glaringlee left a comment

Choose a reason for hiding this comment

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

This LGTM now

Copy link
Contributor

@glaringlee glaringlee left a comment

Choose a reason for hiding this comment

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

@zou3519
Agree unflatten(Tensor, int, namedshape) should be handled.
Just curious, how we handle unflatten(Tensor, str, namedshape)? if input tensor is not named, will user pass str?

@heitorschueroff I think we should add back unflatten(Tensor, int, namedshape)` support

@zou3519
Copy link
Contributor

zou3519 commented Aug 10, 2020

How about this one? unflatten(Tensor, str, namedshape), if input tensor is not named, will user pass str?

On master that errors out, so I'd expect it to give a nice error after this PR

Copy link
Contributor

@glaringlee glaringlee left a comment

Choose a reason for hiding this comment

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

per above comments

Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

Differential Revision: [D23030301](https://our.internmc.facebook.com/intern/diff/D23030301)

[ghstack-poisoned]
Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

Differential Revision: [D23030301](https://our.internmc.facebook.com/intern/diff/D23030301)

[ghstack-poisoned]
Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

Differential Revision: [D23030301](https://our.internmc.facebook.com/intern/diff/D23030301)

[ghstack-poisoned]
Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing all the comments!

I had some minor nits left, feel free to address (or not)

dim, " (", self.size(dim), ") in the input tensor");
}

auto shape = self.sizes().vec();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Using a DimVector gives better performance because it avoids dynamic allocations on the heap when the tensor has <= 5 dimensions:

using DimVector = SmallVector<int64_t, kDimVectorStaticSize>;

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC the usage would be: DimVector shape(self.sizes().begin(), self.sizes().end());

Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

Differential Revision: [D23030301](https://our.internmc.facebook.com/intern/diff/D23030301)

[ghstack-poisoned]
Moved logic for non-named unflatten from python nn module to aten/native to be reused by the nn module later. Fixed some inconsistencies with doc and code logic.

Differential Revision: [D23030301](https://our.internmc.facebook.com/intern/diff/D23030301)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@heitorschueroff merged this pull request in 62bd2dd.

@facebook-github-bot facebook-github-bot deleted the gh/heitorschueroff/1/head branch August 16, 2020 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants