Skip to content

Commit

Permalink
register_buffer for DLRM.triu_indices to make it exportable (#1670)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1670

we need to register buffer for `triu_indices` to make DLRM "exportable" -- thus to generate PT2 IR.

Reviewed By: joshuadeng

Differential Revision: D53233580

fbshipit-source-id: 451c70ea5e3433756b3a351f74e9eedc99cfca0b
  • Loading branch information
wilson100hong authored and facebook-github-bot committed Feb 1, 2024
1 parent 584bb44 commit fc7e83d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions torchrec/models/dlrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ class InteractionArch(nn.Module):
def __init__(self, num_sparse_features: int) -> None:
super().__init__()
self.F: int = num_sparse_features
self.triu_indices: torch.Tensor = torch.triu_indices(
self.F + 1, self.F + 1, offset=1
self.register_buffer(
"triu_indices",
torch.triu_indices(self.F + 1, self.F + 1, offset=1),
persistent=False,
)

def forward(
Expand Down

0 comments on commit fc7e83d

Please sign in to comment.