@@ -0,0 +1,1343 @@
+# RUN: %25PYTHON %25s%0A%0Aimport absl.testing%0Aimport numpy%0Aimport os%0Aimport test_util%0Aimport urllib.request%0A%0Afrom PIL import Image%0A%0A# Model from https://github.com/google-coral/test_data/raw/master/ssd_mobilenet_v2_face_quant_postprocess.tflite%0A# but trimmed the final TFLite_PostProcess op.%0Amodel_path = %22https://storage.googleapis.com/iree-shared-files/models/ssd_mobilenet_v2_face_quant.tflite%22%0A%0Aclass MobilenetSsdQuantTest(test_util.TFLiteModelTest):%0A  def __init__(self, *args, **kwargs):%0A    super(MobilenetSsdQuantTest, self).__init__(model_path, *args, **kwargs)%0A%0A  def compare_results(self, iree_results, tflite_results, details):%0A    super(MobilenetSsdQuantTest, self).compare_results(iree_results, tflite_results, details)%0A    self.assertTrue(numpy.isclose(iree_results%5B0%5D, tflite_results%5B0%5D, atol=1).all())%0A%0A  def generate_inputs(self, input_details):%0A    img_path = %22https://github.com/google-coral/test_data/raw/master/grace_hopper.bmp%22%0A    local_path = %22/%22.join(%5Bself.workdir, %22grace_hopper.bmp%22%5D)%0A    urllib.request.urlretrieve(img_path, local_path)%0A%0A    shape = input_details%5B0%5D%5B%22shape%22%5D%0A    im = numpy.array(Image.open(local_path).resize((shape%5B1%5D, shape%5B2%5D)))%0A    args = %5Bim.reshape(shape)%5D%0A    return args%0A%0A  def test_compile_tflite(self):%0A    self.compile_and_execute()%0A%0Aif __name__ == '__main__':%0A  absl.testing.absltest.main()%0A

Add Mobilenet SSD quant model test (#15)