Created
April 26, 2019 18:16
-
-
Save wanchaol/bb44846d4fcbf6447152a79a6b666c0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@torch.jit.script | |
def test_if_refinement(weight, bias): | |
# type: (Optional[Tensor], Optional[Tensor]) -> Tuple[Optional[int], Optional[int]] | |
if weight is not None and bias is not None: | |
grad_weight = 1 | |
grad_bias = 2 | |
elif weight is not None: | |
grad_weight = 2 | |
grad_bias = None | |
elif bias is not None: | |
grad_weight = None | |
grad_bias = 5 | |
else: | |
grad_weight = None | |
grad_bias = None | |
return (grad_weight, grad_bias) | |
====== | |
RuntimeError: | |
Return value was annotated as having type Tuple[Optional[int], Optional[int]] but is actually of type Tuple[Optional[int], Optional[Optional[int]]]: | |
grad_weight = 2 | |
grad_bias = None | |
elif bias is not None: | |
grad_weight = None | |
grad_bias = 5 | |
else: | |
grad_weight = None | |
grad_bias = None | |
return (grad_weight, grad_bias) | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment