File tree Expand file tree Collapse file tree 12 files changed +129
-0
lines changed Expand file tree Collapse file tree 12 files changed +129
-0
lines changed Original file line number Diff line number Diff line change 219
219
from keras .src .ops .numpy import log2 as log2
220
220
from keras .src .ops .numpy import log10 as log10
221
221
from keras .src .ops .numpy import logaddexp as logaddexp
222
+ from keras .src .ops .numpy import logaddexp2 as logaddexp2
222
223
from keras .src .ops .numpy import logical_and as logical_and
223
224
from keras .src .ops .numpy import logical_not as logical_not
224
225
from keras .src .ops .numpy import logical_or as logical_or
Original file line number Diff line number Diff line change 107
107
from keras .src .ops .numpy import log2 as log2
108
108
from keras .src .ops .numpy import log10 as log10
109
109
from keras .src .ops .numpy import logaddexp as logaddexp
110
+ from keras .src .ops .numpy import logaddexp2 as logaddexp2
110
111
from keras .src .ops .numpy import logical_and as logical_and
111
112
from keras .src .ops .numpy import logical_not as logical_not
112
113
from keras .src .ops .numpy import logical_or as logical_or
Original file line number Diff line number Diff line change 219
219
from keras .src .ops .numpy import log2 as log2
220
220
from keras .src .ops .numpy import log10 as log10
221
221
from keras .src .ops .numpy import logaddexp as logaddexp
222
+ from keras .src .ops .numpy import logaddexp2 as logaddexp2
222
223
from keras .src .ops .numpy import logical_and as logical_and
223
224
from keras .src .ops .numpy import logical_not as logical_not
224
225
from keras .src .ops .numpy import logical_or as logical_or
Original file line number Diff line number Diff line change 107
107
from keras .src .ops .numpy import log2 as log2
108
108
from keras .src .ops .numpy import log10 as log10
109
109
from keras .src .ops .numpy import logaddexp as logaddexp
110
+ from keras .src .ops .numpy import logaddexp2 as logaddexp2
110
111
from keras .src .ops .numpy import logical_and as logical_and
111
112
from keras .src .ops .numpy import logical_not as logical_not
112
113
from keras .src .ops .numpy import logical_or as logical_or
Original file line number Diff line number Diff line change @@ -895,6 +895,15 @@ def logaddexp(x1, x2):
895
895
return jnp .logaddexp (x1 , x2 )
896
896
897
897
898
+ def logaddexp2 (x1 , x2 ):
899
+ x1 = convert_to_tensor (x1 )
900
+ x2 = convert_to_tensor (x2 )
901
+ dtype = dtypes .result_type (x1 .dtype , x2 .dtype , float )
902
+ x1 = cast (x1 , dtype )
903
+ x2 = cast (x2 , dtype )
904
+ return jnp .logaddexp2 (x1 , x2 )
905
+
906
+
898
907
def logical_and (x1 , x2 ):
899
908
x1 = convert_to_tensor (x1 )
900
909
x2 = convert_to_tensor (x2 )
Original file line number Diff line number Diff line change @@ -838,6 +838,13 @@ def logaddexp(x1, x2):
838
838
return np .logaddexp (x1 , x2 )
839
839
840
840
841
+ def logaddexp2 (x1 , x2 ):
842
+ x1 = convert_to_tensor (x1 )
843
+ x2 = convert_to_tensor (x2 )
844
+ dtype = dtypes .result_type (x1 .dtype , x2 .dtype , float )
845
+ return np .logaddexp2 (x1 , x2 ).astype (dtype )
846
+
847
+
841
848
def logical_and (x1 , x2 ):
842
849
return np .logical_and (x1 , x2 )
843
850
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ NumpyDtypeTest::test_isposinf
40
40
NumpyDtypeTest::test_kron
41
41
NumpyDtypeTest::test_lcm
42
42
NumpyDtypeTest::test_linspace
43
+ NumpyDtypeTest::test_logaddexp2
43
44
NumpyDtypeTest::test_logspace
44
45
NumpyDtypeTest::test_matmul_
45
46
NumpyDtypeTest::test_max
@@ -95,6 +96,7 @@ NumpyOneInputOpsCorrectnessTest::test_imag
95
96
NumpyOneInputOpsCorrectnessTest::test_isfinite
96
97
NumpyOneInputOpsCorrectnessTest::test_isinf
97
98
NumpyOneInputOpsCorrectnessTest::test_isposinf
99
+ NumpyOneInputOpsCorrectnessTest::test_logaddexp2
98
100
NumpyOneInputOpsCorrectnessTest::test_max
99
101
NumpyOneInputOpsCorrectnessTest::test_mean
100
102
NumpyOneInputOpsCorrectnessTest::test_median
Original file line number Diff line number Diff line change @@ -1142,6 +1142,12 @@ def logaddexp(x1, x2):
1142
1142
return OpenVINOKerasTensor (result )
1143
1143
1144
1144
1145
+ def logaddexp2 (x1 , x2 ):
1146
+ raise NotImplementedError (
1147
+ "`logaddexp2` is not supported with openvino backend"
1148
+ )
1149
+
1150
+
1145
1151
def logical_and (x1 , x2 ):
1146
1152
x1 = get_ov_output (x1 )
1147
1153
x2 = get_ov_output (x2 )
Original file line number Diff line number Diff line change @@ -1910,6 +1910,22 @@ def logaddexp(x1, x2):
1910
1910
)
1911
1911
1912
1912
1913
+ def logaddexp2 (x1 , x2 ):
1914
+ x1 = tf .convert_to_tensor (x1 )
1915
+ x2 = tf .convert_to_tensor (x2 )
1916
+ dtype = dtypes .result_type (x1 .dtype , x2 .dtype , float )
1917
+ x1 = tf .cast (x1 , dtype )
1918
+ x2 = tf .cast (x2 , dtype )
1919
+ delta = x1 - x2
1920
+ log2 = tf .cast (tf .math .log (2.0 ), dtype )
1921
+ return tf .where (
1922
+ tf .math .is_nan (delta ),
1923
+ x1 + x2 ,
1924
+ tf .maximum (x1 , x2 )
1925
+ + tf .math .log1p (tf .math .exp (- tf .abs (delta ) * log2 )) / log2 ,
1926
+ )
1927
+
1928
+
1913
1929
def logical_and (x1 , x2 ):
1914
1930
x1 = tf .cast (x1 , "bool" )
1915
1931
x2 = tf .cast (x2 , "bool" )
Original file line number Diff line number Diff line change @@ -1054,6 +1054,15 @@ def logaddexp(x1, x2):
1054
1054
return torch .logaddexp (x1 , x2 )
1055
1055
1056
1056
1057
+ def logaddexp2 (x1 , x2 ):
1058
+ x1 = convert_to_tensor (x1 )
1059
+ x2 = convert_to_tensor (x2 )
1060
+ dtype = dtypes .result_type (x1 .dtype , x2 .dtype , float )
1061
+ x1 = cast (x1 , dtype )
1062
+ x2 = cast (x2 , dtype )
1063
+ return torch .logaddexp2 (x1 , x2 )
1064
+
1065
+
1057
1066
def logical_and (x1 , x2 ):
1058
1067
x1 , x2 = convert_to_tensor (x1 ), convert_to_tensor (x2 )
1059
1068
return torch .logical_and (x1 , x2 )
You can’t perform that action at this time.
0 commit comments