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:

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

Differential Revision: D53797660
  • Loading branch information
Yury Gitman authored and facebook-github-bot committed Feb 15, 2024
1 parent 6bf3779 commit 65a34de
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 65a34de

Please sign in to comment.