From: Aswin Murali Date: Fri, 27 Aug 2021 16:02:22 +0000 (-0700) Subject: Adds return type annotation for fork_rng function (#63724) X-Git-Tag: accepted/tizen/8.0/unified/20231005.095509~654 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a43e7a51d7b4c89096510473becffc934644403f;p=platform%2Fupstream%2Fpytorch.git Adds return type annotation for fork_rng function (#63724) Summary: Fixes https://github.com/pytorch/pytorch/issues/63723 Since it's a generator function the type annotation shall be `Generator`. ![image](https://user-images.githubusercontent.com/47299190/130318830-29ef9529-0daa-463c-90b2-1b11f63ade8a.png) Pull Request resolved: https://github.com/pytorch/pytorch/pull/63724 Reviewed By: iramazanli Differential Revision: D30543098 Pulled By: heitorschueroff fbshipit-source-id: ebdd34749defe1e26c899146786a0357ab4b4b9b --- diff --git a/torch/random.py b/torch/random.py index d774634..f5156bf 100644 --- a/torch/random.py +++ b/torch/random.py @@ -1,4 +1,5 @@ import contextlib +from typing import Generator import warnings from torch._C import default_generator @@ -65,7 +66,7 @@ _fork_rng_warned_already = False @contextlib.contextmanager -def fork_rng(devices=None, enabled=True, _caller="fork_rng", _devices_kw="devices"): +def fork_rng(devices=None, enabled=True, _caller="fork_rng", _devices_kw="devices") -> Generator: """ Forks the RNG, so that when you return, the RNG is reset to the state that it was previously in.