File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 15
15
import itertools
16
16
import os
17
17
import random
18
+ import sys
18
19
import types
19
20
import typing
20
21
import unittest
@@ -7091,6 +7092,31 @@ def fn(x):
7091
7092
x = torch .randn (4 )
7092
7093
self .assertEqual (fn (x ), opt_fn (x ))
7093
7094
7095
+ def test_data_dependent_error_log_no_print (self ):
7096
+ # This is a regression test case for
7097
+ # https://github.com/pytorch/pytorch/pull/149831
7098
+ from io import StringIO
7099
+
7100
+ capturedOutput = StringIO ()
7101
+ sys .stderr = capturedOutput
7102
+
7103
+ @torch .compile (fullgraph = True )
7104
+ def func (a ):
7105
+ if a .sum () > 0 :
7106
+ return a + 1
7107
+ return a + 2
7108
+
7109
+ a = torch .rand (10 , 10 )
7110
+ try :
7111
+ func (a )
7112
+ except Exception :
7113
+ pass
7114
+ sys .stderr = sys .__stderr__
7115
+
7116
+ # Make sure we don't _print_ out the graph module.
7117
+ output = capturedOutput .getvalue ()
7118
+ self .assertNotIn ("class GraphModule" , output )
7119
+
7094
7120
7095
7121
instantiate_parametrized_tests (ReproTests )
7096
7122
You can’t perform that action at this time.
0 commit comments