23aef76ed2a1a3d2fc0c3f1949a66b09d3829844,memcnn/models/additive.py,AdditiveBlockFunction,backward,#Any#Any#,163

Before Change


        with set_grad_enabled(True):
            // compute outputs building a sub-graph
            x1_ = Variable(x1.data, requires_grad=True)
            x2_ = Variable(x2.data, requires_grad=True)
            x1_.requires_grad = True
            x2_.requires_grad = True

            y1_ = x1_ + Fm.forward(x2_)
            y2_ = x2_ + Gm.forward(y1_)
            y = torch.cat([y1_, y2_], dim=1)

            // perform full backward pass on graph...
            dd = torch.autograd.grad(y, (x1_, x2_ ) + tuple(Gm.parameters()) + tuple(Fm.parameters()), grad_output)

            GWgrads = dd[2:2+len(GWeights)]
            FWgrads = dd[2+len(GWeights):]
            grad_input = torch.cat([dd[0], dd[1]], dim=1)

            // cleanup sub-graph
            y1_.detach_()
            y2_.detach_()
            del y1_, y2_

        // restore input
        x.data.set_(torch.cat([x1, x2], dim=1).data.contiguous())

After Change



            y1 = x1 + Fm.forward(x2)
            y2 = x2 + Gm.forward(y1)
            y = torch.cat([y1, y2], dim=1)

            // perform full backward pass on graph...
            dd = torch.autograd.grad(y, (x1, x2 ) + tuple(Gm.parameters()) + tuple(Fm.parameters()), grad_output)

            GWgrads = dd[2:2+len(GWeights)]
            FWgrads = dd[2+len(GWeights):]
            grad_input = torch.cat([dd[0], dd[1]], dim=1)

            // cleanup sub-graph
            y1.detach_()
            y2.detach_()
            del y1, y2

        // restore input
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: silvandeleemput/memcnn
Commit Name: 23aef76ed2a1a3d2fc0c3f1949a66b09d3829844
Time: 2018-10-15
Author: tychovdo@gmail.com
File Name: memcnn/models/additive.py
Class Name: AdditiveBlockFunction
Method Name: backward


Project Name: silvandeleemput/memcnn
Commit Name: b73a3eec743aec2411dae5f8a2be7c54d020fb02
Time: 2018-10-15
Author: tychovdo@gmail.com
File Name: memcnn/models/affine.py
Class Name: AffineBlockInverseFunction
Method Name: backward


Project Name: silvandeleemput/memcnn
Commit Name: 23aef76ed2a1a3d2fc0c3f1949a66b09d3829844
Time: 2018-10-15
Author: tychovdo@gmail.com
File Name: memcnn/models/additive.py
Class Name: AdditiveBlockFunction
Method Name: backward


Project Name: silvandeleemput/memcnn
Commit Name: b73a3eec743aec2411dae5f8a2be7c54d020fb02
Time: 2018-10-15
Author: tychovdo@gmail.com
File Name: memcnn/models/affine.py
Class Name: AffineBlockFunction
Method Name: backward