Skip to content

Commit

Permalink
ignore error instead of using Union
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier committed Sep 15, 2020
1 parent 54b6c14 commit 937b956
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions torchvision/models/googlenet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import warnings
from collections import namedtuple
from typing import Union
import torch
import torch.nn as nn
import torch.nn.functional as F
Expand Down Expand Up @@ -194,11 +193,11 @@ def _forward(self, x):
return x, aux2, aux1

@torch.jit.unused
def eager_outputs(self, x: Tensor, aux2: Tensor, aux1: Optional[Tensor]) -> Union[GoogLeNetOutputs, Tensor]:
def eager_outputs(self, x: Tensor, aux2: Tensor, aux1: Optional[Tensor]) -> GoogLeNetOutputs:
if self.training and self.aux_logits:
return _GoogLeNetOutputs(x, aux2, aux1)
else:
return x
return x # type: ignore[return-value]

def forward(self, x):
# type: (Tensor) -> GoogLeNetOutputs
Expand Down
5 changes: 2 additions & 3 deletions torchvision/models/inception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import namedtuple
import warnings
from typing import Union
import torch
import torch.nn as nn
import torch.nn.functional as F
Expand Down Expand Up @@ -189,11 +188,11 @@ def _forward(self, x):
return x, aux

@torch.jit.unused
def eager_outputs(self, x: torch.Tensor, aux: Optional[Tensor]) -> Union[InceptionOutputs, torch.Tensor]:
def eager_outputs(self, x: torch.Tensor, aux: Optional[Tensor]) -> InceptionOutputs:
if self.training and self.aux_logits:
return InceptionOutputs(x, aux)
else:
return x
return x # type: ignore[return-value]

def forward(self, x):
x = self._transform_input(x)
Expand Down

0 comments on commit 937b956

Please sign in to comment.