File tree Expand file tree Collapse file tree 12 files changed +120
-0
lines changed
Expand file tree Collapse file tree 12 files changed +120
-0
lines changed Original file line number Diff line number Diff line change 290290from keras .src .ops .numpy import sign as sign
291291from keras .src .ops .numpy import signbit as signbit
292292from keras .src .ops .numpy import sin as sin
293+ from keras .src .ops .numpy import sinc as sinc
293294from keras .src .ops .numpy import sinh as sinh
294295from keras .src .ops .numpy import size as size
295296from keras .src .ops .numpy import slogdet as slogdet
Original file line number Diff line number Diff line change 171171from keras .src .ops .numpy import sign as sign
172172from keras .src .ops .numpy import signbit as signbit
173173from keras .src .ops .numpy import sin as sin
174+ from keras .src .ops .numpy import sinc as sinc
174175from keras .src .ops .numpy import sinh as sinh
175176from keras .src .ops .numpy import size as size
176177from keras .src .ops .numpy import slogdet as slogdet
Original file line number Diff line number Diff line change 290290from keras .src .ops .numpy import sign as sign
291291from keras .src .ops .numpy import signbit as signbit
292292from keras .src .ops .numpy import sin as sin
293+ from keras .src .ops .numpy import sinc as sinc
293294from keras .src .ops .numpy import sinh as sinh
294295from keras .src .ops .numpy import size as size
295296from keras .src .ops .numpy import slogdet as slogdet
Original file line number Diff line number Diff line change 171171from keras .src .ops .numpy import sign as sign
172172from keras .src .ops .numpy import signbit as signbit
173173from keras .src .ops .numpy import sin as sin
174+ from keras .src .ops .numpy import sinc as sinc
174175from keras .src .ops .numpy import sinh as sinh
175176from keras .src .ops .numpy import size as size
176177from keras .src .ops .numpy import slogdet as slogdet
Original file line number Diff line number Diff line change @@ -1249,6 +1249,16 @@ def sin(x):
12491249 return jnp .sin (x )
12501250
12511251
1252+ def sinc (x ):
1253+ x = convert_to_tensor (x )
1254+ if standardize_dtype (x .dtype ) == "int64" :
1255+ dtype = config .floatx ()
1256+ else :
1257+ dtype = dtypes .result_type (x .dtype , float )
1258+ x = cast (x , dtype )
1259+ return jnp .sinc (x )
1260+
1261+
12521262@sparse .elementwise_unary (linear = False )
12531263def sinh (x ):
12541264 x = convert_to_tensor (x )
Original file line number Diff line number Diff line change @@ -1233,6 +1233,16 @@ def sin(x):
12331233 return np .sin (x )
12341234
12351235
1236+ def sinc (x ):
1237+ x = convert_to_tensor (x )
1238+ if standardize_dtype (x .dtype ) == "int64" :
1239+ dtype = config .floatx ()
1240+ else :
1241+ dtype = dtypes .result_type (x .dtype , float )
1242+ x = x .astype (dtype )
1243+ return np .sinc (x ).astype (dtype )
1244+
1245+
12361246def sinh (x ):
12371247 x = convert_to_tensor (x )
12381248 if standardize_dtype (x .dtype ) == "int64" :
Original file line number Diff line number Diff line change @@ -357,6 +357,7 @@ NumpyDtypeTest::test_minimum_python_types
357357NumpyDtypeTest::test_nanargmax
358358NumpyDtypeTest::test_nanargmin
359359NumpyDtypeTest::test_power
360+ NumpyDtypeTest::test_sinc
360361NumpyDtypeTest::test_view
361362NumpyOneInputOpsCorrectnessTest::test_array
362363NumpyOneInputOpsCorrectnessTest::test_conj
@@ -366,10 +367,13 @@ NumpyOneInputOpsCorrectnessTest::test_nanargmax
366367NumpyOneInputOpsCorrectnessTest::test_nanargmin
367368NumpyOneInputOpsCorrectnessTest::test_real
368369NumpyOneInputOpsCorrectnessTest::test_reshape
370+ NumpyOneInputOpsCorrectnessTest::test_sinc
369371NumpyOneInputOpsCorrectnessTest::test_slogdet
370372NumpyOneInputOpsCorrectnessTest::test_vectorize
371373NumpyOneInputOpsCorrectnessTest::test_view
374+ NumpyOneInputOpsDynamicShapeTest::test_sinc
372375NumpyOneInputOpsDynamicShapeTest::test_view
376+ NumpyOneInputOpsStaticShapeTest::test_sinc
373377NumpyOneInputOpsStaticShapeTest::test_view
374378OptimizerTest::test_constraints_are_applied
375379OptimizerTest::test_ema
Original file line number Diff line number Diff line change @@ -3556,6 +3556,12 @@ def sin(x):
35563556 return OpenVINOKerasTensor (ov_opset .sin (x ).output (0 ))
35573557
35583558
3559+ def sinc (x ):
3560+ raise NotImplementedError (
3561+ "`sinc` is not supported with the OpenVINO backend."
3562+ )
3563+
3564+
35593565def sinh (x ):
35603566 x = get_ov_output (x )
35613567 x_type = x .get_element_type ()
Original file line number Diff line number Diff line change @@ -2707,6 +2707,21 @@ def sin(x):
27072707 return tf .math .sin (x )
27082708
27092709
2710+ def sinc (x ):
2711+ x = convert_to_tensor (x )
2712+ if standardize_dtype (x .dtype ) == "int64" :
2713+ dtype = config .floatx ()
2714+ else :
2715+ dtype = dtypes .result_type (x .dtype , float )
2716+ x = tf .cast (x , dtype )
2717+ pi_x = x * tf .constant (np .pi , dtype = x .dtype )
2718+ return tf .where (
2719+ tf .equal (x , 0 ),
2720+ tf .ones_like (x ),
2721+ tf .math .sin (pi_x ) / pi_x ,
2722+ )
2723+
2724+
27102725@sparse .elementwise_unary
27112726def sinh (x ):
27122727 x = convert_to_tensor (x )
Original file line number Diff line number Diff line change @@ -1721,6 +1721,11 @@ def sin(x):
17211721 return torch .sin (x )
17221722
17231723
1724+ def sinc (x ):
1725+ x = convert_to_tensor (x )
1726+ return torch .sinc (x )
1727+
1728+
17241729def sinh (x ):
17251730 x = convert_to_tensor (x )
17261731 return torch .sinh (x )
You can’t perform that action at this time.
0 commit comments