@@ -269,10 +269,32 @@ def aten_angle(self: TensorType) -> TensorType:
269
269
raise NotImplementedError ()
270
270
271
271
272
- def aten_any (self : TensorType ) -> TensorType :
272
+ @torch_op ("aten::any" , trace_only = True )
273
+ def aten_any (self : TTensor , dim : Optional [int ] = None , keepdim : bool = True ) -> BOOL :
273
274
"""any(Tensor self) -> Tensor"""
274
275
275
- raise NotImplementedError ()
276
+ minus_1 = op .Constant (value_ints = [- 1 ])
277
+ self_rank = op .Size (op .Shape (self ))
278
+ if self_rank == 0 :
279
+ self = op .Reshape (self , minus_1 )
280
+
281
+ zero = op .Constant (value_float = 0.0 )
282
+ result = op .Not (op .Equal (self , zero ))
283
+ # because op.ReduceMax() cannot calculate BOOL value
284
+ result_float = op .Cast (result , to = FLOAT .dtype )
285
+
286
+ if op .OptionalHasElement (dim ):
287
+ dim = op .Reshape (dim , minus_1 )
288
+ dims = op .Cast (dim , to = INT64 .dtype )
289
+ result_max = op .ReduceMax (result_float , dims , keepdims = keepdim , noop_with_empty_axes = 0 )
290
+ else :
291
+ result_max = op .ReduceMax (result_float , keepdims = 0 , noop_with_empty_axes = 0 )
292
+
293
+ result = op .Greater (result_max , zero )
294
+ if self_rank == 0 :
295
+ result = op .Squeeze (result )
296
+
297
+ return result
276
298
277
299
278
300
def _range_supported (dtype : int ) -> bool :
@@ -2044,10 +2066,13 @@ def aten_expand(self: TTensor, size: TInt) -> TTensor:
2044
2066
return op .Expand (self , size )
2045
2067
2046
2068
2047
- def aten_expand_as (self : TensorType , other : TensorType ) -> TensorType :
2069
+ @torch_op ("aten::expand_as" )
2070
+ def aten_expand_as (self : TTensor , other : TTensor ) -> TTensor :
2048
2071
"""expand_as(Tensor(a) self, Tensor other) -> Tensor(a)"""
2049
2072
2050
- raise NotImplementedError ()
2073
+ shape = op .Shape (other )
2074
+ result = op .Expand (self , shape )
2075
+ return result
2051
2076
2052
2077
2053
2078
def aten_expand_copy (self : TensorType , size : INT64 , implicit : bool = False ) -> TensorType :
0 commit comments