File tree 2 files changed +20
-2
lines changed
function_libs/torch_aten/ops
tests/function_libs/torch_aten 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -5053,10 +5053,20 @@ def aten_square(self: TensorType) -> TensorType:
5053
5053
raise NotImplementedError ()
5054
5054
5055
5055
5056
- def aten_squeeze (self : TensorType ) -> TensorType :
5056
+ @torch_op ("aten::squeeze" , trace_only = True )
5057
+ def aten_squeeze (self : TTensor , dim : Optional [int ] = None ) -> TTensor :
5057
5058
"""squeeze(Tensor(a) self) -> Tensor(a)"""
5058
5059
5059
- raise NotImplementedError ()
5060
+ if op .OptionalHasElement (dim ):
5061
+ rank = op .Size (op .Shape (self ))
5062
+ if rank == 0 :
5063
+ self = op .Reshape (self , op .Constant (value_ints = [- 1 ]))
5064
+ dims = op .Reshape (dim , op .Constant (value_ints = [- 1 ]))
5065
+ result = op .Squeeze (self , dims )
5066
+ else :
5067
+ result = op .Squeeze (self )
5068
+
5069
+ return result
5060
5070
5061
5071
5062
5072
def aten_squeeze_copy (self : TensorType ) -> TensorType :
Original file line number Diff line number Diff line change @@ -412,6 +412,7 @@ def _where_input_wrangler(
412
412
),
413
413
"ones_like" : core_ops .aten_ones_like ,
414
414
"slice" : core_ops .aten_slice ,
415
+ "squeeze" : core_ops .aten_squeeze ,
415
416
"sum" : (core_ops .aten_sum_dim_IntList , _sum_input_wrangler ),
416
417
"transpose" : core_ops .aten_transpose ,
417
418
"zeros_like" : core_ops .aten_zeros_like ,
@@ -556,6 +557,13 @@ def _where_input_wrangler(
556
557
matcher = lambda sample : len (sample .args [0 ]) == 0 ,
557
558
reason = "Empty perm is not supported" ,
558
559
),
560
+ skip (
561
+ "squeeze" ,
562
+ matcher = lambda sample : len (sample .args ) > 0
563
+ and len (sample .input .shape ) > 0
564
+ and sample .input .shape [sample .args [0 ]] != 1 ,
565
+ reason = "Cannot select an axis to squeeze out which has size not equal to one" ,
566
+ ),
559
567
)
560
568
561
569
duplicate_opinfo (
You can’t perform that action at this time.
0 commit comments