guard against special case of in-place operation
guard against special case of in-place operation

Summary:
There is an edge case where internal gradient blobs of the backward step net should not be considered internally calclulated if the only "internal" calculation is in-place.

In the case of the failing attention unit tests, the offending blob was attention_weighted_encoder_context_grad, which was incorrectly considered internal because it was the output (as well as input) of a Reshape on the step net's edge. The caveat here is that the results may be unpredictable if a non-pass-through in-place operation is applied to a blob within a step net which is also consumed both internally and is a recurrent state/output. (This is an extreme edge case, and difficult to explicitly enforce, but it's worth noting.)

Reviewed By: salexspb

Differential Revision: D5198328

fbshipit-source-id: 0cfa8f903fd767fc50e727f238ac3d8cdca03fe0

sf-wind/caffe2,xzturn/caffe2,pietern/caffe2,Yangqing/caffe2,xzturn/caffe2,Yangqing/caffe2,davinwang/caffe2,davinwang/caffe2,pietern/caffe2,xzturn/caffe2,bwasti/caffe2,davinwang/caffe2,pietern/caffe2,pietern/caffe2,bwasti/caffe2,sf-wind/caffe2,xzturn/caffe2,bwasti/caffe2,davinwang/caffe2,sf-wind/caffe2,sf-wind/caffe2,Yangqing/caffe2,Yangqing/caffe2,caffe2/caffe2,xzturn/caffe2,bwasti/caffe2,Yangqing/caffe2,davinwang/caffe2,pietern/caffe2,sf-wind/caffe2,bwasti/caffe2