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

Function do_flop

tools/analyze_model.py:34–49  ·  view source on GitHub ↗
(cfg)

Source from the content-addressed store, hash-verified

32
33
34def do_flop(cfg):
35 data_loader = build_detection_test_loader(cfg, cfg.DATASETS.TEST[0])
36 model = build_model(cfg)
37 DetectionCheckpointer(model).load(cfg.MODEL.WEIGHTS)
38 model.eval()
39
40 counts = Counter()
41 total_flops = []
42 for idx, data in zip(tqdm.trange(args.num_inputs), data_loader): # noqa
43 count = flop_count_operators(model, data)
44 counts += count
45 total_flops.append(sum(count.values()))
46 logger.info(
47 "(G)Flops for Each Type of Operators:\n" + str([(k, v / idx) for k, v in counts.items()])
48 )
49 logger.info("Total (G)Flops: {}±{}".format(np.mean(total_flops), np.std(total_flops)))
50
51
52def do_activation(cfg):

Callers

nothing calls this directly

Calls 5

build_modelFunction · 0.90
flop_count_operatorsFunction · 0.90
loadMethod · 0.80

Tested by

no test coverage detected