Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utilities for deterministic unit tests (facebookresearch#497)
Summary: Pull Request resolved: facebookresearch#497 A longstanding pain point of ours has been writing unit tests that (a) are nontrivial enough to catch any regressions, and (b) don't break every time we add a new test case, change model initialization order, or perform other superficial refactors. Random initialization usually passes (a) but fails (b), while deterministic initialization ([e.g.](https://github.com/facebookresearch/multimodal/blob/2ddb8cdb205f2035e88e4fafb7e88cccb7b99705/tests/test_utils.py#L192)) does the opposite. This diff introduces a utility for constructing deterministic but nontrivial tensors of any shape, with flexibility so the user can determine the tensor's range. As an easy extension, we also add a utility to initialize nn.Module parameters in the same way. Reviewed By: abhinavarora Differential Revision: D50251029 fbshipit-source-id: 26a95a30cd55ac01b04dbfb687955f35e8202de5
- Loading branch information