Skip to content

Commit a6e96b1

Browse files
authored
Avoid leaking has_torch_function and handle_torch_function in torch namespace (pytorch#46680) (pytorch#46719)
Summary: Pull Request resolved: pytorch#46680 Reviewed By: zou3519 Differential Revision: D24459823 Pulled By: albanD fbshipit-source-id: 4ff6925afcf14214dc45921bca0d2f33ca1944a1
1 parent f9df694 commit a6e96b1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torch/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,12 @@ def compiled_with_cxx11_abi():
614614
quantized_lstm = torch.ops.aten.quantized_lstm
615615
quantized_gru = torch.ops.aten.quantized_gru
616616

617-
from .overrides import has_torch_function, handle_torch_function
618617

619618
def Assert(condition, message):
620619
r"""A wrapper around Python's assert which is symbolically traceable.
621620
"""
621+
from .overrides import has_torch_function, handle_torch_function
622+
622623
if type(condition) is not torch.Tensor and has_torch_function((condition,)):
623624
return handle_torch_function(Assert, (condition,), condition, message)
624625
assert condition, message

0 commit comments

Comments
 (0)