File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -6338,6 +6338,30 @@ def forward(self, x):
6338
6338
res = opt_mod (x )
6339
6339
self .assertEqual (ref , res )
6340
6340
6341
+ def test_symnode_is_op (self ):
6342
+ @torch .compile (backend = "eager" , fullgraph = True , dynamic = True )
6343
+ def f (x , xs ):
6344
+ if x .size (0 ) is xs :
6345
+ return x + 1
6346
+ else :
6347
+ return x * 2
6348
+
6349
+ t = torch .randn (2 )
6350
+ res = f (t , [1 , 2 ])
6351
+ self .assertEqual (t * 2 , res )
6352
+
6353
+ def test_symnode_is_not_op (self ):
6354
+ @torch .compile (backend = "eager" , fullgraph = True , dynamic = True )
6355
+ def f (x , xs ):
6356
+ if x .size (0 ) is not xs :
6357
+ return x + 1
6358
+ else :
6359
+ return x * 2
6360
+
6361
+ t = torch .randn (2 )
6362
+ res = f (t , [1 , 2 ])
6363
+ self .assertEqual (t + 1 , res )
6364
+
6341
6365
6342
6366
instantiate_parametrized_tests (ReproTests )
6343
6367
Original file line number Diff line number Diff line change 69
69
"<=" : operator .le ,
70
70
"==" : operator .eq ,
71
71
"!=" : operator .ne ,
72
+ "is" : operator .is_ ,
73
+ "is not" : operator .is_not ,
72
74
}
73
75
# Ops that allow tensor <op> None
74
76
supported_const_comparison_ops = {
You can’t perform that action at this time.
0 commit comments