Exemple #1
0
    def test_without_experimental_new_converter(self):
        args = [
            '--saved_model_dir=/tmp/saved_model/',
            '--output_file=/tmp/output.tflite',
        ]

        # V1 parser.
        parser = tflite_convert._get_parser(False)
        parsed_args = parser.parse_args(args)
        self.assertFalse(parsed_args.experimental_new_converter)

        # V2 parser.
        parser = tflite_convert._get_parser(True)
        parsed_args = parser.parse_args(args)
        self.assertFalse(parsed_args.experimental_new_converter)
    def test_experimental_new_quantizer(self):
        args = [
            '--saved_model_dir=/tmp/saved_model/',
            '--output_file=/tmp/output.tflite',
            '--experimental_new_quantizer',
        ]

        # V1 parser.
        parser = tflite_convert._get_parser(use_v2_converter=False)
        parsed_args = parser.parse_args(args)
        self.assertTrue(parsed_args.experimental_new_quantizer)

        # V2 parser.
        parser = tflite_convert._get_parser(use_v2_converter=True)
        parsed_args = parser.parse_args(args)
        self.assertTrue(parsed_args.experimental_new_quantizer)
    def test_without_experimental_new_converter(self):
        args = [
            '--saved_model_dir=/tmp/saved_model/',
            '--output_file=/tmp/output.tflite',
        ]

        # Note that when the flag parses to None, the converter uses the default
        # value, which is True.

        # V1 parser.
        parser = tflite_convert._get_parser(use_v2_converter=False)
        parsed_args = parser.parse_args(args)
        self.assertIsNone(parsed_args.experimental_new_converter)

        # V2 parser.
        parser = tflite_convert._get_parser(use_v2_converter=True)
        parsed_args = parser.parse_args(args)
        self.assertIsNone(parsed_args.experimental_new_converter)
  def test_experimental_new_quantizer(self, use_v2_converter, new_quantizer):
    args = [
        '--saved_model_dir=/tmp/saved_model/',
        '--output_file=/tmp/output.tflite',
        '--experimental_new_quantizer={}'.format(new_quantizer),
    ]

    parser = tflite_convert._get_parser(use_v2_converter=use_v2_converter)
    parsed_args = parser.parse_args(args)
    self.assertEqual(parsed_args.experimental_new_quantizer, new_quantizer)
  def test_experimental_new_converter_none(self, use_v2_converter):
    args = [
        '--saved_model_dir=/tmp/saved_model/',
        '--output_file=/tmp/output.tflite',
        '--experimental_new_converter',
    ]

    parser = tflite_convert._get_parser(use_v2_converter=use_v2_converter)
    parsed_args = parser.parse_args(args)
    self.assertTrue(parsed_args.experimental_new_converter)