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
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()
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')
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
- Read upRead up
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,
- Read upRead up
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,
- Read upRead up
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,
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,
- Read upRead up
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)
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
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,
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(
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)
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,
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()
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()
- Read upRead up
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,
- Read upRead up
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,
- Read upRead up
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()
- Read upRead up
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(
Function testBiasQuantization
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def testBiasQuantization(
Function testIntegerQuantizationWithUnsupportedOps
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def testIntegerQuantizationWithUnsupportedOps(
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,
- Read upRead up
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,
- Read upRead up
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,
- Read upRead up
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"