MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / flop_count_operators

Function flop_count_operators

detectron2/utils/analysis.py:53–73  ·  view source on GitHub ↗

Implement operator-level flops counting using jit. This is a wrapper of fvcore.nn.flop_count, that supports standard detection models in detectron2. Note: The function runs the input through the model to compute flops. The flops of a detection model is often input-d

(
    model: nn.Module, inputs: list, **kwargs
)

Source from the content-addressed store, hash-verified

51
52
53def flop_count_operators(
54 model: nn.Module, inputs: list, **kwargs
55) -> typing.DefaultDict[str, float]:
56 """
57 Implement operator-level flops counting using jit.
58 This is a wrapper of fvcore.nn.flop_count, that supports standard detection models
59 in detectron2.
60
61 Note:
62 The function runs the input through the model to compute flops.
63 The flops of a detection model is often input-dependent, for example,
64 the flops of box & mask head depends on the number of proposals &
65 the number of detected objects.
66 Therefore, the flops counting using a single input may not accurately
67 reflect the computation cost of a model.
68
69 Args:
70 model: a detectron2 model that takes `list[dict]` as input.
71 inputs (list[dict]): inputs to model, in detectron2's standard format.
72 """
73 return _wrapper_count_operators(model=model, inputs=inputs, mode=FLOPS_MODE, **kwargs)
74
75
76def activation_count_operators(

Callers 3

do_flopFunction · 0.90
test_flopMethod · 0.90
test_flopMethod · 0.90

Calls 1

_wrapper_count_operatorsFunction · 0.85

Tested by 2

test_flopMethod · 0.72
test_flopMethod · 0.72