Skip to content

Commit

Permalink
Update on "opcheck should be usable without optional dependencies"
Browse files Browse the repository at this point in the history
This PR excises opcheck's dependency on
torch.testing._internal.common_utils, (which comes with dependencies on
expecttest and hypothesis). We do this by moving what we need to
torch.testing._utils and adding a test for it.

Fixes #126870, #126871

Test Plan:
- new tests

[ghstack-poisoned]
  • Loading branch information
zou3519 committed May 28, 2024
1 parent 4cc2d75 commit aec3eaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch/testing/_internal/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
has_pytest = False


def freeze_rng_state(*args, **kwargs):
return torch.testing._utils.freeze_rng_state(*args, **kwargs)


# Class to keep track of test flags configurable by environment variables.
# Flags set here are intended to be read-only and should not be modified after
# definition.
Expand Down
2 changes: 2 additions & 0 deletions torch/testing/_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import contextlib

import torch
from torch.utils._mode_utils import no_dispatch

# Common testing utilities for use in public testing APIs.
# NB: these should all be importable without optional dependencies
# (like numpy and expecttest).


def wrapper_set_seed(op, *args, **kwargs):
"""Wrapper to set seed manually for some functions like dropout
See: https://github.com/pytorch/pytorch/pull/62315#issuecomment-896143189 for more details.
Expand Down

0 comments on commit aec3eaf

Please sign in to comment.