@@ -5541,6 +5541,36 @@ def func(x):
5541
5541
x_val = np .array ([1 , 5 , 2 , 0 , 3 , 4 ], dtype = np .int64 )
5542
5542
self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val })
5543
5543
5544
+ @check_tf_min_version ("2.1" )
5545
+ @skip_tflite ("TFlite errors on some attributes" )
5546
+ @check_opset_min_version (9 , "string" )
5547
+ def test_asstring (self ):
5548
+ def func (x ):
5549
+ op_ = tf .strings .as_string (x )
5550
+ return tf .identity (op_ , name = _TFOUTPUT )
5551
+
5552
+ x_val = np .array ([0 , 1 , 2 , 3 ], dtype = np .int32 )
5553
+ self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val })
5554
+
5555
+ x_val = np .array ([0 , 1 , 2 , 3 ], dtype = np .float32 )
5556
+ # can't check the values because in onnx they are padded with 0, in tf they are not
5557
+ self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val }, check_value = False )
5558
+
5559
+ @check_tf_min_version ("2.1" )
5560
+ @skip_tflite ("TFlite errors on some attributes" )
5561
+ @check_opset_min_version (9 , "string" )
5562
+ def test_string_to_number (self ):
5563
+ def func (x ):
5564
+ op_ = tf .strings .to_number (x )
5565
+ return tf .identity (op_ , name = _TFOUTPUT )
5566
+
5567
+ # tf gets this wrong and returns fp32 instead of int
5568
+ x_val = np .array ("123" , dtype = np .object )
5569
+ self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val })
5570
+
5571
+ x_val = np .array ("123.1" , dtype = np .object )
5572
+ # can't check the values because in onnx they are padded with 0, in tf they are not
5573
+ self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val }, check_value = False )
5544
5574
5545
5575
5546
5576
if __name__ == '__main__' :
0 commit comments