MCPcopy Create free account

hub / github.com/MrYxJ/calculate-flops.pytorch / functions

Functions71 in github.com/MrYxJ/calculate-flops.pytorch

↓ 44 callersFunctionwrapFunc
(func, funcFlopCompute, old_functions, module_flop_count, module_mac_count)
calflops/pytorch_ops.py:353
↓ 15 callersFunction_prod
(dims)
calflops/pytorch_ops.py:31
↓ 9 callersFunctionmacs_to_string
Converts macs in numeric form to string form. Args: macs (int): Calculate the results of the model macs in numerical form. units
calflops/utils.py:197
↓ 8 callersFunctionflops_to_string
Converts flops in numeric form to string form. Args: flops (int): Calculate the results of the model flops in numerical form. uni
calflops/utils.py:211
↓ 7 callersFunctionparams_to_string
Converts params in numeric form to string form. Args: params_num (int): Calculate the results of the model param in numerical form.
calflops/utils.py:239
↓ 5 callersFunctionnumber_to_string
(num, units=None, precision=DEFAULT_PRECISION)
calflops/utils.py:163
↓ 4 callersFunctioncalculate_flops
Returns the total floating-point operations, MACs, and parameters of a model. Args: model ([torch.nn.Module]): The model of input must be
calflops/flops_counter.py:25
↓ 4 callersFunctiongenerate_transformer_input
Automatically generates data in the form of transformes model input format. Args: input_shape (tuple):transformers model input shape:
calflops/utils.py:94
↓ 4 callersMethodget_total_flops
Returns the total flops of the model. Args: as_string (bool, optional): whether to output the flops as string. Defaults to False.
calflops/calculate_pipline.py:165
↓ 4 callersMethodget_total_macs
Returns the total MACs of the model. Args: as_string (bool, optional): whether to output the flops as string. Defaults to False.
calflops/calculate_pipline.py:177
↓ 4 callersMethodget_total_params
Returns the total number of parameters stored per rank. Args: as_string (bool, optional): whether to output the parameters as str
calflops/calculate_pipline.py:189
↓ 4 callersFunctionmake_row
(left_char, middle_char, right_char)
calflops/estimate.py:153
↓ 3 callersFunctionget_module_flops
Recursively compute the FLOP s of the model Args: module (pytorch module): model format must be pytorch is_sparse (bool, Optional
calflops/utils.py:254
↓ 3 callersFunctionget_module_macs
Recursively compute the macs s of the model Args: module (pytorch module): model format must be pytorch is_sparse (bool, Optional
calflops/utils.py:273
↓ 2 callersFunction_elementwise_flops_compute
(input, other)
calflops/pytorch_ops.py:328
↓ 2 callersFunction_rnn_flops
(flops, rnn_module, w_ih, w_hh, input_size)
calflops/pytorch_ops.py:371
↓ 2 callersMethodend_flops_calculate
Ends the pipline of calculating FLOPs. The added attributes and handles are removed recursively on all the modules.
calflops/calculate_pipline.py:145
↓ 2 callersMethodstart_flops_calculate
Starts the pipline of calculating FLOPs. Extra attributes are added recursively to all the modules and the calculate torch.nn.functionals are
calflops/calculate_pipline.py:60
↓ 1 callersFunction_patch_functionals
(old_functions, module_flop_count, module_mac_count)
calflops/pytorch_ops.py:452
↓ 1 callersFunction_patch_tensor_methods
(old_functions, module_flop_count, module_mac_count)
calflops/pytorch_ops.py:506
↓ 1 callersFunction_reload_functionals
(old_functions)
calflops/pytorch_ops.py:528
↓ 1 callersFunction_reload_tensor_methods
(old_functions)
calflops/pytorch_ops.py:567
↓ 1 callersFunctioncalculate_flops_hf
Returns the total floating-point operations, MACs, and parameters of a model. Args: model_name (str): The model name in huggingface platf
calflops/flops_counter_hf.py:28
↓ 1 callersFunctioncreate_empty_model
Creates an empty model from its parent library on the `Hub` to calculate the overall memory consumption. Args: model_name (`str`):
calflops/estimate.py:64
↓ 1 callersMethodprint_model_pipline
Prints the model graph with the calculateing pipline attached to each module. Args: module_depth (int, optional): The depth of th
calflops/calculate_pipline.py:299
↓ 1 callersMethodprint_return_model_pipline
Prints the model graph with the calculateing pipline attached to each module. Args: module_depth (int, optional): The depth of th
calflops/calculate_pipline.py:202
↓ 1 callersMethodreset_flops_calculate
Resets the pipline of calculating FLOPs. Adds or resets the extra attributes, include flops、macs、params.
calflops/calculate_pipline.py:128
↓ 1 callersMethodstop_flops_calculate
Stop the pipline of calculating FLOPs. All torch.nn.functionals are restored to their originals.
calflops/calculate_pipline.py:105
↓ 1 callersFunctionverify_on_hub
Verifies that the model is on the hub and returns the model info.
calflops/estimate.py:38
Method__init__
Init Pipline of Calculating the FLOPs about model. Args: model (pytorch model): The model must be a pytorh model now.
calflops/calculate_pipline.py:45
Function_add_flops_compute
(input, other, *, alpha=1, out=None)
calflops/pytorch_ops.py:324
Function_addmm_flops_compute
Count flops for the addmm operation.
calflops/pytorch_ops.py:282
Function_batch_norm_flops_compute
( input, running_mean, running_var, weight=None, bias=None, training=False, moment
calflops/pytorch_ops.py:174
Function_conv_flops_compute
(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1)
calflops/pytorch_ops.py:83
Function_conv_trans_flops_compute
( input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, d
calflops/pytorch_ops.py:128
Function_dropout_flops_compute
(input, p=0.5, training=True, inplace=False)
calflops/pytorch_ops.py:270
Function_einsum_flops_compute
Count flops for the einsum operation.
calflops/pytorch_ops.py:290
Function_elu_flops_compute
(input: Tensor, alpha: float = 1.0, inplace: bool = False)
calflops/pytorch_ops.py:51
Function_embedding_flops_compute
( input, weight, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=Fa
calflops/pytorch_ops.py:258
Function_gelu_flops_compute
(input, **kwargs)
calflops/pytorch_ops.py:67
Function_group_norm_flops_compute
(input: Tensor, num_groups: int, weight: Optional[
calflops/pytorch_ops.py:204
Function_instance_norm_flops_compute
( input: Tensor, running_mean: Optional[Tensor] = None, running_var: Optional[Tensor] = None,
calflops/pytorch_ops.py:214
Function_is_package_available
(pkg_name)
calflops/utils.py:302
Function_layer_norm_flops_compute
( input: Tensor, normalized_shape: List[int], weight: Optional[Tensor] = None, bias: Optional[
calflops/pytorch_ops.py:192
Function_leaky_relu_flops_compute
(input: Tensor, negative_slope: float = 0.01, inplace: bool = False)
calflops/pytorch_ops.py:55
Function_linear_flops_compute
(input, weight, bias=None)
calflops/pytorch_ops.py:37
Function_matmul_flops_compute
Count flops for the matmul operation.
calflops/pytorch_ops.py:274
Function_mul_flops_compute
(input, other, *, out=None)
calflops/pytorch_ops.py:320
Function_pool_flops_compute
(input, kernel_size, stride=None, padd
calflops/pytorch_ops.py:71
Function_prelu_flops_compute
(input: Tensor, weight: Tensor)
calflops/pytorch_ops.py:47
Function_relu6_flops_compute
(input: Tensor, inplace: bool = False)
calflops/pytorch_ops.py:59
Function_relu_flops_compute
(input, inplace=False)
calflops/pytorch_ops.py:43
Function_rnn_cell_forward_hook
(rnn_cell_module, input, output)
calflops/pytorch_ops.py:425
Function_rnn_forward_hook
(rnn_module, input, output)
calflops/pytorch_ops.py:397
Function_silu_flops_compute
(input: Tensor, inplace: bool = False)
calflops/pytorch_ops.py:63
Function_softmax_flops_compute
(input, dim=None, _stacklevel=3, dtype=None)
calflops/pytorch_ops.py:254
Function_tensor_addmm_flops_compute
Count flops for the tensor addmm operation.
calflops/pytorch_ops.py:312
Function_upsample_flops_compute
(*args, **kwargs)
calflops/pytorch_ops.py:229
Methodadd_extra_repr
(module)
calflops/calculate_pipline.py:262
Methodadd_or_reset_attrs
(module)
calflops/calculate_pipline.py:134
Functionbytes_to_string
Converts bytes in numeric form to string form. Args: b (int): Calculate the results of the bytes in numerical form. units (str, o
calflops/utils.py:225
Functioncheck_has_model
Checks what library spawned `error` when a model is not found
calflops/estimate.py:48
Functionconvert_bytes
Converts `size` from bytes to the largest possible unit
calflops/utils.py:292
Functioncreate_ascii_table
Creates a pretty table from a list of rows, minimal version of `tabulate`.
calflops/estimate.py:139
Methoddel_extra_repr
(module)
calflops/calculate_pipline.py:269
Methodflops_repr
(module)
calflops/calculate_pipline.py:244
FunctionnewFunc
(*args, **kwds)
calflops/pytorch_ops.py:358
Methodpost_hook
(module, input, output)
calflops/calculate_pipline.py:91
Methodpre_hook
(module, input)
calflops/calculate_pipline.py:84
Methodregister_module_hooks
(module, ignore_list)
calflops/calculate_pipline.py:73
Methodremove_calculate_attrs
(module)
calflops/calculate_pipline.py:115