Skip to content

Commit

Permalink
Fix cuda/cpu check on NoneType (#88854)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #88854

Fix cuda/cpu check on NoneType

Test Plan: sabdcastle/ github CI/CD

Reviewed By: drisspg

Differential Revision: D41203955

fbshipit-source-id: b44de88b8f7f856706ee76a4a5702f392b07075b
  • Loading branch information
mikekgfb authored and facebook-github-bot committed Nov 11, 2022
1 parent 495e7b1 commit 7192859
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch/nn/modules/activation.py
Expand Up @@ -1114,7 +1114,7 @@ def forward(self, query: Tensor, key: Tensor, value: Tensor, key_padding_mask: O
# generator expressions.
if torch.overrides.has_torch_function(tensor_args):
why_not_fast_path = "some Tensor argument has_torch_function"
elif not all([(x.is_cuda or 'cpu' in str(x.device)) for x in tensor_args]):
elif not all([(x is None or x.is_cuda or 'cpu' in str(x.device)) for x in tensor_args]):
why_not_fast_path = "some Tensor argument is neither CUDA nor CPU"
elif torch.is_grad_enabled() and any([x.requires_grad for x in tensor_args]):
why_not_fast_path = ("grad is enabled and at least one of query or the "
Expand Down

0 comments on commit 7192859

Please sign in to comment.