Skip to content

Commit

Permalink
Replace torch.jit.instance with instance to assist torch.compile (#522)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #522

torch.jit.instance is mainly needed to refine Generics, but in this case instance is sufficient, instance unlike torch.jit.instance is also playing nicely with torch.compile

Reviewed By: ebsmothers

Differential Revision: D53797660

fbshipit-source-id: b8e4c5542be866bb09dd331ece4725ae8f57dfcf
  • Loading branch information
Yury Gitman authored and facebook-github-bot committed Feb 15, 2024
1 parent 6bf3779 commit 1cccc58
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions torchmultimodal/modules/layers/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,8 @@ def _cross_attention_block(
# TODO: figure out caching for cross-attention
use_cache=False,
)
assert torch.jit.isinstance(
output, Tensor
), "cross-attention output must be Tensor."
assert isinstance(output, Tensor), "cross-attention output must be Tensor."

attention_output = self.cross_attention_dropout(output)
return attention_output

Expand Down

0 comments on commit 1cccc58

Please sign in to comment.