Skip to content

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Nov 7, 2017

The first two commits are just a little bit of refactoring.

The next two support defining gradient for multiple inputs simultaneously in derivatives.yaml, and then an example of how to use it via atan2. The basic model is, instead of saying output1: returns a tensor and output2: returns a tensor, you just say output1, output2: returns a tuple of tensors

I am not entirely sure I have done the output_mask handling idiomatically. This definitely seems like an opportunity for some compiler-y techniques. For example, one way to implement this assuming you have a working compiler is to define the computation once assuming every output is needed, and then for every output_mask permutation, DCE the unneeded outputs. (This is, of course, assuming that there isn't a totally different algorithm that is applicable when you can remove required grads; in the case of atan2, this is definitely not the case.) In any case I don't plan to do this on this PR.

Looking at derivatives.yaml, here are some more opportunities for reusing intermediate computations with addbmm and dist (which already have gradients.) I'll do these once I confirm the pattern looks good.

@pytorchbot
Copy link
Collaborator

@ezyang, thanks for your PR! We identified @zdevito to be a potential reviewer.

@ezyang ezyang requested a review from colesbury November 7, 2017 08:01

This comment was marked as off-topic.

This comment was marked as off-topic.

@ezyang
Copy link
Contributor Author

ezyang commented Nov 7, 2017

I also pushed a fairly hefty piece of documentation on the top of derivatives.yaml.

Copy link
Member

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

Nice lgtm!

This comment was marked as off-topic.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
…atives.yaml

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
@ezyang ezyang force-pushed the pr/backward-intermediate branch from e4316fe to 4131990 Compare November 8, 2017 05:54
@ezyang
Copy link
Contributor Author

ezyang commented Nov 8, 2017

Pushed some PR comment fixes, and squashed some lint commits. I'll merge this when CI passes.

@ezyang ezyang merged commit 8d2b9a0 into pytorch:master Nov 8, 2017
@ezyang ezyang deleted the pr/backward-intermediate branch April 3, 2018 16:45
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.

4 participants