File quantize_model_test.py
has 6044 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2022 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
StaticRangeQuantizationTest
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class StaticRangeQuantizationTest(quantize_model_test_base.QuantizedModelTest):
@parameterized.parameters(
testing.parameter_combinations([{
'shapes': [
Function test_conv_ptq_model
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def test_conv_ptq_model(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
has_batch_norm: bool,
- 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 test_function_alias_preserved
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def test_function_alias_preserved(self):
model = self._create_conv2d_model(
input_shape=(1, 3, 4, 3), filter_shape=(2, 3, 3, 2)
)
- 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 test_qat_matmul_model
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_qat_matmul_model(
self,
shapes: Sequence[Tuple[_TensorShape, _TensorShape]],
activation_fn: Optional[ops.Operation],
has_bias: bool,
Function test_qat_matmul_model
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def test_qat_matmul_model(
self,
shapes: Sequence[Tuple[_TensorShape, _TensorShape]],
activation_fn: Optional[ops.Operation],
has_bias: bool,
- 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 test_depthwise_conv_ptq_model
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def test_depthwise_conv_ptq_model(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
has_batch_norm: bool,
- 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 test_conv3d_ptq_model
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_conv3d_ptq_model(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
has_batch_norm: bool,
Function test_function_alias_preserved_in_qat
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def test_function_alias_preserved_in_qat(self):
_, y_shape, _, x_signature, y_signature = (
self._prepare_sample_einsum_datashapes('ab,bc->ac')
)
model = self._create_einsum_model(
- 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 test_function_alias_preserved
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def test_function_alias_preserved(self):
# Prepare test model
function_alias = 'conv_func'
tags = {tag_constants.SERVING}
input_type, filter_shape = dtypes.int64, (2, 3, 3, 2)
- 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 test_qat_einsum_model_with_batchmatmul_conversion
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_qat_einsum_model_with_batchmatmul_conversion(
self,
equation: str,
shape_unknown: bool,
activation_fn: Optional[ops.Operation],
Function test_einsum_ptq_model
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_einsum_ptq_model(
self,
equation: str,
target_opset: quant_opts_pb2.OpSet,
):
Function test_conv2d_ptq_model_per_layer_verify
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_conv2d_ptq_model_per_layer_verify(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
debugger_type: _DebuggerConfig.DebuggerType,
Function test_conv_ptq_model
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_conv_ptq_model(
Function test_model_ptq_with_uncalibrated_subgraph
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def test_model_ptq_with_uncalibrated_subgraph(self):
class IfModel(module.Module):
"""A model that contains a branching op."""
def __init__(self):
- 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 test_conv3d_ptq_model
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_conv3d_ptq_model(
Function test_depthwise_conv_ptq_model
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_depthwise_conv_ptq_model(
Function test_matmul_with_reshape_and_bias_ptq_model
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_matmul_with_reshape_and_bias_ptq_model(
Function test_qat_conv_model
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def test_qat_conv_model(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
has_batch_norm: bool,
- 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 test_conv_ptq_model_by_calibration_options
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def test_conv_ptq_model_by_calibration_options(
self,
target_opset: quant_opts_pb2.OpSet,
calibration_options: stablehlo_quant_config_pb2.CalibrationOptions,
):
- 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 test_qat_einsum_model_with_batchmatmul_conversion
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_qat_einsum_model_with_batchmatmul_conversion(
Function test_qat_einsum_model_with_xla
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_qat_einsum_model_with_xla(
Function test_conv2d_ptq_model_per_layer_verify
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def test_conv2d_ptq_model_per_layer_verify(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
debugger_type: _DebuggerConfig.DebuggerType,
- 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 test_matmul_ptq_model
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_matmul_ptq_model(
Function test_qat_conv_model
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_qat_conv_model(
Function test_depthwise_conv_model
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def test_depthwise_conv_model(
self,
target_opset: quant_opts_pb2.OpSet,
enable_per_channel_quantization: bool,
):
- 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 test_conv3d_ptq_model
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def test_conv3d_ptq_model(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
has_batch_norm: bool,
- 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 test_matmul_ptq_model
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def test_matmul_ptq_model(
self,
activation_fn: Optional[ops.Operation],
has_bias: bool,
batch_sizes: Sequence[int],
- 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 test_conv_model
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def test_conv_model(
self,
target_opset: quant_opts_pb2.OpSet,
enable_per_channel_quantization: bool,
):
- 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 test_gather_model_tf1
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def test_gather_model_tf1(
self, target_opset: quant_opts_pb2.OpSet, use_variable: bool
):
signature_key = signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY
tags = {tag_constants.SERVING}
- 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"