tensorflow/tensorflow

View on GitHub
tensorflow/lite/python/lite_v2_test.py

Summary

Maintainability
F
2 wks
Test Coverage

File lite_v2_test.py has 4420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in tensorflow/lite/python/lite_v2_test.py - About 1 wk to fix

    FromConcreteFunctionTest has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FromConcreteFunctionTest(lite_v2_test_util.ModelTest):
    
      @test_util.run_v2_only
      def testTypeInvalid(self):
        root = self._getSimpleVariableModel()
    Severity: Minor
    Found in tensorflow/lite/python/lite_v2_test.py - About 6 hrs to fix

      FromSavedModelTest has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class FromSavedModelTest(lite_v2_test_util.ModelTest):
      
        def _createV1SavedModel(self, shape):
          """Create a simple SavedModel."""
          saved_model_dir = os.path.join(self.get_temp_dir(), 'simple_savedmodel')
      Severity: Minor
      Found in tensorflow/lite/python/lite_v2_test.py - About 5 hrs to fix

        Function testQATLowBitKerasModel has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          def testQATLowBitKerasModel(self, num_bits, weight_only, low_bit):
            bit_max = (1 << (num_bits - 1)) - 1
            bit_min = -bit_max
            tf_input_shape = (5, 5, 3)
            tflite_input_shape = (1,) + tf_input_shape
        Severity: Minor
        Found in tensorflow/lite/python/lite_v2_test.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function testMlirDynamicRangeQuantization has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def testMlirDynamicRangeQuantization(
              self,
              enable_new_dynamic_range_quantizer,
              disable_per_channel,
              enable_float16_quant,
        Severity: Minor
        Found in tensorflow/lite/python/lite_v2_test.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function testMlirDynamicRangeQuantization has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def testMlirDynamicRangeQuantization(
              self,
              enable_new_dynamic_range_quantizer,
              disable_per_channel,
              enable_float16_quant,
        Severity: Minor
        Found in tensorflow/lite/python/lite_v2_test.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function testMultipleFunctionQuantizedModel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def testMultipleFunctionQuantizedModel(
              self,
              is_int_only,
              is_int16_quantize,
              inference_input_output_type,
        Severity: Minor
        Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

          Function testMultipleFunctionQuantizedModel has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def testMultipleFunctionQuantizedModel(
                self,
                is_int_only,
                is_int16_quantize,
                inference_input_output_type,
          Severity: Minor
          Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function testConvertMultipleFunctions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def testConvertMultipleFunctions(self):
              """Convert multiple functions in a multi-functional model."""
              root = self._getMultiFunctionModel()
              input_data = tf.constant(1.0, shape=[1])
              add_func = root.add.get_concrete_function(input_data)
          Severity: Minor
          Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

            Function testSignatureDefsWithFullIntegerQuantization has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def testSignatureDefsWithFullIntegerQuantization(self):
                # SETUP
                # 1. Define input shapes
                tf_input_shape = (32, 32, 128)
                tflite_input_shape = (1,) + tf_input_shape
            Severity: Minor
            Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

              Function testMlirDynamicRangeQuantization has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def testMlirDynamicRangeQuantization(
                    self,
                    enable_new_dynamic_range_quantizer,
                    disable_per_channel,
                    enable_float16_quant,
              Severity: Minor
              Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

                Function testPostTrainingCalibrateAndQuantize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def testPostTrainingCalibrateAndQuantize(self, mlir_quantizer):
                    root, func, calibration_gen = self._getIntegerQuantizeModel()
                
                    # Convert float model.
                    float_converter = lite.TFLiteConverterV2.from_concrete_functions(
                Severity: Minor
                Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

                  Function testMultipleFunctionModel has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def testMultipleFunctionModel(self):
                      """Convert multiple functions in a multi-functional model."""
                      root = self._getMultiFunctionModel()
                      input_data = tf.constant(1.0, shape=[1])
                      add_func = root.add.get_concrete_function(input_data)
                  Severity: Minor
                  Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

                    Function testMlirDynamicRangeQuantization has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def testMlirDynamicRangeQuantization(
                          self,
                          enable_new_dynamic_range_quantizer,
                          disable_per_channel,
                          enable_float16_quant,
                    Severity: Minor
                    Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

                      Function testIntegerQuantization has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def testIntegerQuantization(
                            self, is_int_only, is_int16_quantize, inference_input_output_type
                        ):
                          root, func, calibration_gen = self._getIntegerQuantizeModel()
                      
                      
                      Severity: Minor
                      Found in tensorflow/lite/python/lite_v2_test.py - About 1 hr to fix

                        Function testIntegerQuantizationWithFlexOp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def testIntegerQuantizationWithFlexOp(
                              self, is_int_only, is_int16_quantize, inference_input_output_type
                          ):
                            root, func, calibration_gen = self._getIntegerQuantizationModelWithFlexOp()
                        
                        
                        Severity: Minor
                        Found in tensorflow/lite/python/lite_v2_test.py - About 55 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function testIntegerQuantizationWithUnsupportedOps has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def testIntegerQuantizationWithUnsupportedOps(
                              self,
                              is_int_only,
                              is_int16_quantize,
                              inference_input_output_type,
                        Severity: Minor
                        Found in tensorflow/lite/python/lite_v2_test.py - About 55 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function testIntegerQuantizationWithControlFlow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def testIntegerQuantizationWithControlFlow(
                              self,
                              is_int_only,
                              is_int16_quantize,
                              inference_input_output_type,
                        Severity: Minor
                        Found in tensorflow/lite/python/lite_v2_test.py - About 45 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function testIntegerQuantization has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def testIntegerQuantization(
                              self, is_int_only, is_int16_quantize, inference_input_output_type
                          ):
                            root, func, calibration_gen = self._getIntegerQuantizeModel()
                        
                        
                        Severity: Minor
                        Found in tensorflow/lite/python/lite_v2_test.py - About 45 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function testIntegerQuantizationWithControlFlow has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def testIntegerQuantizationWithControlFlow(
                        Severity: Minor
                        Found in tensorflow/lite/python/lite_v2_test.py - About 35 mins to fix

                          Function testBiasQuantization has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            def testBiasQuantization(
                          Severity: Minor
                          Found in tensorflow/lite/python/lite_v2_test.py - About 35 mins to fix

                            Function testIntegerQuantizationWithUnsupportedOps has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              def testIntegerQuantizationWithUnsupportedOps(
                            Severity: Minor
                            Found in tensorflow/lite/python/lite_v2_test.py - About 35 mins to fix

                              Function testDisablePerChannelQuantizationForDenseLayers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def testDisablePerChannelQuantizationForDenseLayers(
                                    self,
                                    disable_per_channel_for_dense=False,
                                    enable_mlir_quantizer=False,
                                    representative_dataset=False,
                              Severity: Minor
                              Found in tensorflow/lite/python/lite_v2_test.py - About 35 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function testDisablePerChannelQuantization has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def testDisablePerChannelQuantization(
                                    self,
                                    disable_per_channel=False,
                                    enable_mlir_quantizer=False,
                                    representative_dataset=True,
                              Severity: Minor
                              Found in tensorflow/lite/python/lite_v2_test.py - About 35 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function testBiasQuantization has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def testBiasQuantization(
                                    self,
                                    is_int16_quantize,
                                    explicitly_set_bias,
                                    bias_type,
                              Severity: Minor
                              Found in tensorflow/lite/python/lite_v2_test.py - About 35 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              There are no issues that match your filters.

                              Category
                              Status