9b664bd7cd8dbb9657626166ba61887ed06774d7,gpytorch/utils/toeplitz.py,,index_coef_to_sparse,#Any#Any#Any#,6
Before Change
num_target_points, num_coefficients = value_matrix.size()
index_list = [[], []]
value_list = []
for i in range(num_target_points):
for j in range(num_coefficients):
if value_matrix[i, j] == 0:
continue
After Change
value_tensor = value_matrix.view(-1)
nonzero_indices = value_tensor.nonzero()
if nonzero_indices.storage():
nonzero_indices.squeeze_()
index_tensor = index_tensor.index_select(1, nonzero_indices)
value_tensor = value_tensor.index_select(0, nonzero_indices)
else:
index_tensor = index_tensor.resize_(2, 1).zero_()
value_tensor = value_tensor.resize_(1).zero_()
res = torch.sparse.FloatTensor(index_tensor, value_tensor, torch.Size([num_target_points, row_length]))
return res
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: cornellius-gp/gpytorch
Commit Name: 9b664bd7cd8dbb9657626166ba61887ed06774d7
Time: 2017-09-13
Author: gpleiss@gmail.com
File Name: gpytorch/utils/toeplitz.py
Class Name:
Method Name: index_coef_to_sparse
Project Name: pytorch/fairseq
Commit Name: d0ccc3e02e1a9015d05cade8dfc61896948275c7
Time: 2020-06-22
Author: myleott@fb.com
File Name: fairseq/models/lstm.py
Class Name: LSTMDecoder
Method Name: reorder_incremental_state
Project Name: OpenNMT/OpenNMT-py
Commit Name: 128ea5274db96163c58a99405e7205abcab36192
Time: 2017-08-28
Author: srush@seas.harvard.edu
File Name: onmt/Translator.py
Class Name: Translator
Method Name: translate