6e58890709c68a24c2773cb744804362aef4a23b,dnc/memory.py,Memory,allocate,#Memory#Any#Any#,83
Before Change
// https://discuss.pytorch.org/t/cumprod-exclusive-true-equivalences/2614/8
v = var(T.ones(batch_size, 1))
if self.gpu_id != -1:
v = v.cuda(self.gpu_id)
cat_sorted_usage = T.cat((v, sorted_usage), 1)[:, :-1]
prod_sorted_usage = fake_cumprod(cat_sorted_usage, self.gpu_id)
sorted_allocation_weights = (1 - sorted_usage) * prod_sorted_usage.squeeze()
After Change
// cumprod with exclusive=True
// https://discuss.pytorch.org/t/cumprod-exclusive-true-equivalences/2614/8
v = var(sorted_usage.data.new(batch_size, 1).fill_(1))
cat_sorted_usage = T.cat((v, sorted_usage), 1)
prod_sorted_usage = T.cumprod(cat_sorted_usage, 1)[:, :-1]
sorted_allocation_weights = (1 - sorted_usage) * prod_sorted_usage.squeeze()
// construct the reverse sorting index https://stackoverflow.com/questions/2483696/undo-or-reverse-argsort-python
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 5
Instances
Project Name: ixaxaar/pytorch-dnc
Commit Name: 6e58890709c68a24c2773cb744804362aef4a23b
Time: 2017-11-12
Author: root@ixaxaar.in
File Name: dnc/memory.py
Class Name: Memory
Method Name: allocate
Project Name: pytorch/examples
Commit Name: a7a5cdc598afd6afa3d0e9d355360bebc4947c29
Time: 2017-01-24
Author: bryan.mccann.is@gmail.com
File Name: snli/model.py
Class Name: Encoder
Method Name: forward
Project Name: ixaxaar/pytorch-dnc
Commit Name: 89c379db757a53851145180a3437b6b110334a7c
Time: 2017-11-12
Author: root@ixaxaar.in
File Name: dnc/memory.py
Class Name: Memory
Method Name: allocate