1515import bitarray
1616import bitarray .util
1717import numpy as np
18- import tensorflow as tf
18+ import unittest
1919
2020from tflite_micro .tensorflow .lite .micro .compression import compress
2121from tflite_micro .tensorflow .lite .micro .compression import metadata_py_generated as schema
2525from tflite_micro .tensorflow .lite .python import schema_py_generated as tflite
2626
2727
28- class TestPackIndices (tf . test .TestCase ):
28+ class TestPackIndices (unittest .TestCase ):
2929
3030 def test_basic_case (self ):
3131 indices = np .array ([1 , 2 , 3 ])
@@ -112,7 +112,7 @@ def test_bitwidth_7(self):
112112 self .assertEqual (result , expected_bytes )
113113
114114
115- class TestPackLookupTables (tf . test .TestCase ):
115+ class TestPackLookupTables (unittest .TestCase ):
116116
117117 def test_int16_positive (self ):
118118 tables = [np .array ([0x1234 , 0x5678 ], dtype = '<i2' )]
@@ -361,7 +361,7 @@ def test_multiple_tables_with_padding(self):
361361# yapf: enable
362362
363363
364- class TestsCompression (tf . test .TestCase ):
364+ class TestsCompression (unittest .TestCase ):
365365 """Tests with the uncompressed model."""
366366
367367 @classmethod
@@ -435,7 +435,7 @@ def test_no_axis(self):
435435 lambda : compress .compress (self .flatbuffer , specs ))
436436
437437
438- class TestLutCompressedArray (tf . test .TestCase ):
438+ class TestLutCompressedArray (unittest .TestCase ):
439439
440440 def test_bitwidth (self ):
441441 """Bitwidth is determined from index values."""
@@ -453,7 +453,7 @@ def test_bitwidth(self):
453453 self .assertEqual (a .index_bitwidth , 1 )
454454
455455
456- class TestCompressedModel (tf . test .TestCase ):
456+ class TestCompressedModel (unittest .TestCase ):
457457 """Test the compressed model."""
458458
459459 @classmethod
@@ -538,7 +538,7 @@ def test_compressed_uint8(self):
538538 self .assertEqual (indices , expected_indices )
539539
540540 expected_values = np .array (range (16 ), dtype = "<u1" )
541- self . assertAllEqual (values , expected_values )
541+ np . testing . assert_array_equal (values , expected_values )
542542
543543 def test_compressed_int8 (self ):
544544 bitwidth , indices , values = self ._get_compressed (subgraph = 0 , tensor = 1 )
@@ -555,7 +555,7 @@ def test_compressed_int8(self):
555555 self .assertEqual (indices , expected_indices )
556556
557557 expected_values = np .array (range (- 16 , 0 ), dtype = "<i1" )
558- self . assertAllEqual (values , expected_values )
558+ np . testing . assert_array_equal (values , expected_values )
559559
560560 def test_compressed_int16 (self ):
561561 bitwidth , indices , values = self ._get_compressed (subgraph = 0 , tensor = 2 )
@@ -572,7 +572,7 @@ def test_compressed_int16(self):
572572 self .assertEqual (indices , expected_indices )
573573
574574 expected_values = np .array (range (- 1616 , - 1600 ), dtype = "<i2" )
575- self . assertAllEqual (values , expected_values )
575+ np . testing . assert_array_equal (values , expected_values )
576576
577577 def test_compressed_int32 (self ):
578578 bitwidth , indices , values = self ._get_compressed (subgraph = 0 , tensor = 3 )
@@ -589,7 +589,7 @@ def test_compressed_int32(self):
589589 self .assertEqual (indices , expected_indices )
590590
591591 expected_values = np .array (range (- 160_016 , - 160_000 ), dtype = "<i4" )
592- self . assertAllEqual (values , expected_values )
592+ np . testing . assert_array_equal (values , expected_values )
593593
594594 def test_axis_1 (self ):
595595 """Compression along quanitzation_dimension == 1."""
@@ -607,7 +607,7 @@ def test_axis_1(self):
607607 self .assertEqual (indices , expected_indices )
608608
609609 expected_values = np .array (range (1 , 21 ), dtype = np .dtype ("<i2" ))
610- self . assertAllEqual (values , expected_values )
610+ np . testing . assert_array_equal (values , expected_values )
611611
612612 def test_axis_0 (self ):
613613 """Compression along quanitzation_dimension == 0."""
@@ -626,7 +626,7 @@ def test_axis_0(self):
626626 self .assertEqual (indices , expected_indices )
627627
628628 expected_values = np .array (range (1 , 21 ), dtype = np .dtype ("<i2" ))
629- self . assertAllEqual (values , expected_values )
629+ np . testing . assert_array_equal (values , expected_values )
630630
631631 def test_per_tensor (self ):
632632 """Compression with one value table per tensor."""
@@ -645,8 +645,8 @@ def test_per_tensor(self):
645645 self .assertEqual (indices , expected_indices )
646646
647647 expected_values = np .array (range (1 , 5 ), dtype = np .dtype ("<i2" ))
648- self . assertAllEqual (values , expected_values )
648+ np . testing . assert_array_equal (values , expected_values )
649649
650650
651651if __name__ == "__main__" :
652- tf . test .main ()
652+ unittest .main ()
0 commit comments