Skip to content

Commit

Permalink
Implementation of left padding for issue #1077
Browse files Browse the repository at this point in the history
Implementation of left padding for issue #1077. This is based on a suggestion
by @gabrielspmoreira. I am not exactly sure if this change will completely
work, and this is untested due to current failing tests on main on this part of
the codebase. But the motivation of this commit is to start a commit for
comments, suggestions, and revisions on this issue's implementation.
  • Loading branch information
Adam Lesnikowski committed Sep 16, 2021
1 parent ed61663 commit ff1e396
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nvtabular/loader/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ def _get_sparse_tensor(self, values, indices, num_rows, seq_limit):
sparse_tensor = sparse_tensor.to_dense()
return sparse_tensor

def _build_sparse_tensor(self, values, offsets, diff_offsets, num_rows, seq_limit):
def _build_sparse_tensor(self, values, offsets, diff_offsets, num_rows, seq_limit, padding=None):
indices = self._get_indices(offsets, diff_offsets)
if padding == "left":
indices[:,1] = seq_limit - 1 - indices[:,1]
if padding == "right":
raise NotImplementedError
return self._get_sparse_tensor(values, indices, num_rows, seq_limit)


Expand Down

0 comments on commit ff1e396

Please sign in to comment.