@@ -394,6 +394,35 @@ def test_forward_squeeze():
394394 _test_squeeze (np .arange (6 ).reshape ((1 , 2 , 1 , 3 )), [0 , 2 ])
395395 _test_squeeze (np .arange (6 ).reshape ((2 , 1 , 3 , 1 )), [1 , 3 ])
396396
397+
398+ #######################################################################
399+ # Pad
400+ # ---
401+
402+ def _test_pad (data ):
403+ """ One iteration of PAD """
404+
405+ assert len (data ) == 2
406+
407+ # Test with tensor and constant
408+ with tf .Graph ().as_default ():
409+ in_data = [array_ops .placeholder (shape = data [0 ].shape , dtype = data [0 ].dtype , name = 'in' )]
410+ out = array_ops .pad (in_data [0 ], ops .convert_to_tensor (data [1 ], dtype = data [1 ].dtype ))
411+ compare_tflite_with_tvm ([data [0 ]], ['in:0' ], in_data , [out ])
412+
413+
414+ def test_forward_pad ():
415+ """ Pad """
416+ _test_pad ([np .arange (1.0 , 7.0 , dtype = np .float32 ).reshape ((2 , 1 , 1 , 3 )),
417+ np .array ([[1 , 1 ], [2 , 2 ], [1 , 1 ], [2 , 2 ]], dtype = np .int32 )])
418+ _test_pad ([np .arange (1.0 , 7.0 , dtype = np .float32 ).reshape ((2 , 1 , 3 )),
419+ np .array ([[2 , 2 ], [1 , 1 ], [1 , 1 ]], dtype = np .int32 )])
420+ _test_pad ([np .arange (1.0 , 7.0 , dtype = np .float32 ).reshape ((2 , 3 )),
421+ np .array ([[1 , 1 ], [2 , 2 ]], dtype = np .int32 )])
422+ _test_pad ([np .arange (1.0 , 4.0 , dtype = np .float32 ).reshape ((1 , 3 )),
423+ np .array ([[1 , 1 ], [2 , 2 ]], dtype = np .int32 )])
424+
425+
397426#######################################################################
398427# Softmax
399428# -------
@@ -528,6 +557,7 @@ def test_forward_inception_v4_net():
528557if __name__ == '__main__' :
529558 # Transforms
530559 test_forward_concatenation ()
560+ test_forward_pad ()
531561 test_forward_reshape ()
532562 test_forward_squeeze ()
533563
0 commit comments