File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -711,6 +711,27 @@ def __contains__(self, item):
711
711
Tensor .var = ops .var
712
712
StubTensor .var = ops .var
713
713
714
+ Tensor .logsumexp = ops .logsumexp
715
+ StubTensor .logsumexp = ops .logsumexp
716
+
717
+ def __bool__ (self ):
718
+ if self .ndim > 0 :
719
+ return True
720
+ return bool (self ._item ())
721
+
722
+ Tensor .__bool__ = __bool__
723
+ StubTensor .__bool__ = __bool__
724
+
725
+ def __iter__ (self ):
726
+ if self .ndim == 0 :
727
+ yield self
728
+ else :
729
+ for i in range (len (self )):
730
+ yield self [i ]
731
+
732
+ Tensor .__iter__ = __iter__
733
+ StubTensor .__iter__ = __iter__
734
+
714
735
def _rebuild_from_type_v2 (func , new_type , args , state ):
715
736
ret = func (* args )
716
737
return ret
Original file line number Diff line number Diff line change @@ -1044,6 +1044,9 @@ def cartesian_prod(*tensors):
1044
1044
def detach (input ):
1045
1045
return ops .stop_gradient (input )
1046
1046
1047
+ def cosine_similarity (* args , ** kwargs ):
1048
+ return core .nn .functional .cosine_similarity (* args , ** kwargs )
1049
+
1047
1050
__all__ = [
1048
1051
"bincount" ,
1049
1052
"broadcast_shapes" ,
@@ -1081,5 +1084,6 @@ def detach(input):
1081
1084
"histc" ,
1082
1085
"view_as_complex" ,
1083
1086
"view_as_real" ,
1084
- "detach"
1087
+ "detach" ,
1088
+ "cosine_similarity"
1085
1089
]
You can’t perform that action at this time.
0 commit comments