nncf/common/pruning/utils.py
def count_flops_and_weights(graph: NNCFGraph,
                            input_shapes: Dict[NNCFNodeName, List[int]],
                            output_shapes: Dict[NNCFNodeName, List[int]],
                            conv_op_metatypes: List[Type[OperatorMetatype]],
                            linear_op_metatypes: List[Type[OperatorMetatype]],
                            input_channels: Dict[NNCFNodeName, int] = None,
                            output_channels: Dict[NNCFNodeName, int] = None,
                            kernel_sizes: Dict[NNCFNodeName, Tuple[int, int]] = None,
                            op_addresses_to_skip: List[str] = None
                            ) -> Tuple[int, int]:
    """
    Counts the number weights and FLOPs in the model for convolution and fully connected layers.

    :param graph: NNCFGraph.
    :param input_shapes: Dictionary of input dimension shapes for convolutions and
        fully connected layers. E.g {node_name: (height, width)}
    :param output_shapes: Dictionary of output dimension shapes for convolutions and
        fully connected layers. E.g {node_name: (height, width)}
    :param conv_op_metatypes: List of metatypes defining convolution operations.
    :param linear_op_metatypes: List of metatypes defining linear/fully connected operations.
    :param input_channels: Dictionary of input channels number in convolutions.
        If not specified, taken from the graph. {node_name: channels_num}
    :param output_channels: Dictionary of output channels number in convolutions.
        If not specified, taken from the graph. {node_name: channels_num}
    :param kernel_sizes: Dictionary of kernel sizes in convolutions.
        If not specified, taken from the graph. {node_name: kernel_size}. It's only supposed to be used in NAS in case
        of Elastic Kernel enabled.
    :param op_addresses_to_skip: List of operation addresses of layers that should be skipped from calculation.
        It's only supposed to be used in NAS in case of Elastic Depth enabled.
    :return number of FLOPs for the model
            number of weights (params) in the model
    """
    flops_pers_node, weights_per_node = count_flops_and_weights_per_node(graph,
                                                                         input_shapes, output_shapes,
                                                                         conv_op_metatypes, linear_op_metatypes,
                                                                         input_channels, output_channels,
                                                                         kernel_sizes, op_addresses_to_skip)
    return sum(flops_pers_node.values()), sum(weights_per_node.values())

    Counts the number weights and FLOPs in the model for convolution and fully connected layers.

    :param graph: NNCFGraph.
    :param input_shapes: Dictionary of input dimension shapes for convolutions and
        fully connected layers. E.g {node_name: (height, width)}
    :param output_shapes: Dictionary of output dimension shapes for convolutions and
        fully connected layers. E.g {node_name: (height, width)}
    :param conv_op_metatypes: List of metatypes defining convolution operations.
    :param linear_op_metatypes: List of metatypes defining linear/fully connected operations.
    :param input_channels: Dictionary of input channels number in convolutions.
        If not specified, taken from the graph. {node_name: channels_num}
    :param output_channels: Dictionary of output channels number in convolutions.
        If not specified, taken from the graph. {node_name: channels_num}
    :param kernel_sizes: Dictionary of kernel sizes in convolutions.
        If not specified, taken from the graph. {node_name: kernel_size}. It's only supposed to be used in NAS in case
        of Elastic Kernel enabled.
    :param op_addresses_to_skip: List of operation addresses of layers that should be skipped from calculation.
        It's only supposed to be used in NAS in case of Elastic Depth enabled.
    :return number of FLOPs for the model
            number of weights (params) in the model
    
Counts the number weights and FLOPs in the model for convolution and fully connected layers.
Counts the number weights and FLOPs in the model for convolution and fully connected layers .
def count_flops_and_weights(graph: NNCFGraph,
                            input_shapes: Dict[NNCFNodeName, List[int]],
                            output_shapes: Dict[NNCFNodeName, List[int]],
                            conv_op_metatypes: List[Type[OperatorMetatype]],
                            linear_op_metatypes: List[Type[OperatorMetatype]],
                            input_channels: Dict[NNCFNodeName, int] = None,
                            output_channels: Dict[NNCFNodeName, int] = None,
                            kernel_sizes: Dict[NNCFNodeName, Tuple[int, int]] = None,
                            op_addresses_to_skip: List[str] = None
                            ) -> Tuple[int, int]:
    flops_pers_node, weights_per_node = count_flops_and_weights_per_node(graph,
                                                                         input_shapes, output_shapes,
                                                                         conv_op_metatypes, linear_op_metatypes,
                                                                         input_channels, output_channels,
                                                                         kernel_sizes, op_addresses_to_skip)
    return sum(flops_pers_node.values()), sum(weights_per_node.values())
def count_flops_and_weights ( graph : NNCFGraph , input_shapes : Dict [ NNCFNodeName , List [ int ] ] , output_shapes : Dict [ NNCFNodeName , List [ int ] ] , conv_op_metatypes : List [ Type [ OperatorMetatype ] ] , linear_op_metatypes : List [ Type [ OperatorMetatype ] ] , input_channels : Dict [ NNCFNodeName , int ] = None , output_channels : Dict [ NNCFNodeName , int ] = None , kernel_sizes : Dict [ NNCFNodeName , Tuple [ int , int ] ] = None , op_addresses_to_skip : List [ str ] = None ) -> Tuple [ int , int ] : flops_pers_node , weights_per_node = count_flops_and_weights_per_node ( graph , input_shapes , output_shapes , conv_op_metatypes , linear_op_metatypes , input_channels , output_channels , kernel_sizes , op_addresses_to_skip ) return sum ( flops_pers_node . values ( ) ) , sum ( weights_per_node . values ( ) )
Counts the number weights and FLOPs in the model for convolution and fully connected layers.
Counts the number weights and FLOPs in the model for convolution and fully connected layers .
"""
    Counts the number weights and FLOPs in the model for convolution and fully connected layers.

    :param graph: NNCFGraph.
    :param input_shapes: Dictionary of input dimension shapes for convolutions and
        fully connected layers. E.g {node_name: (height, width)}
    :param output_shapes: Dictionary of output dimension shapes for convolutions and
        fully connected layers. E.g {node_name: (height, width)}
    :param conv_op_metatypes: List of metatypes defining convolution operations.
    :param linear_op_metatypes: List of metatypes defining linear/fully connected operations.
    :param input_channels: Dictionary of input channels number in convolutions.
        If not specified, taken from the graph. {node_name: channels_num}
    :param output_channels: Dictionary of output channels number in convolutions.
        If not specified, taken from the graph. {node_name: channels_num}
    :param kernel_sizes: Dictionary of kernel sizes in convolutions.
        If not specified, taken from the graph. {node_name: kernel_size}. It's only supposed to be used in NAS in case
        of Elastic Kernel enabled.
    :param op_addresses_to_skip: List of operation addresses of layers that should be skipped from calculation.
        It's only supposed to be used in NAS in case of Elastic Depth enabled.
    :return number of FLOPs for the model
            number of weights (params) in the model
    """
graph
NNCFGraph
input_shapes
Dict[NNCFNodeName, List[int]]
output_shapes
Dict[NNCFNodeName, List[int]]
conv_op_metatypes
List[Type[OperatorMetatype]]
linear_op_metatypes
List[Type[OperatorMetatype]]
input_channels
Dict[NNCFNodeName, int]
output_channels
Dict[NNCFNodeName, int]
kernel_sizes
Dict[NNCFNodeName, Tuple[int, int]]
op_addresses_to_skip
List[str]