-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide PyTorch trace compilation warnings
The test execution shows warnings about traces being potentially incorrect because the Python3 control flow is not completely recorded. This includes conditions on the shape of the integration domain tensor. Since the only arguments of the compiled integration function are the integrand and integration domain, and the dimensionality of this integration domain is constant, we can ignore the warnings. After this change, the two `get_jit_compiled_integrate` functions hide PyTorch trace compilation warnings with `warnings.filterwarnings`.
- Loading branch information
Showing
3 changed files
with
26 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import warnings | ||
|
||
|
||
def _torch_trace_without_warnings(*args, **kwargs): | ||
"""Execute `torch.jit.trace` on the passed arguments and hide tracer warnings | ||
PyTorch can show warnings about traces being potentially incorrect because | ||
the Python3 control flow is not completely recorded. | ||
This function can be used to hide the warnings in situations where they are | ||
false positives. | ||
""" | ||
import torch | ||
|
||
with warnings.catch_warnings(): | ||
warnings.filterwarnings("ignore", category=torch.jit.TracerWarning) | ||
return torch.jit.trace(*args, **kwargs) |