MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / unflatten_process_benchmark_dict

Function unflatten_process_benchmark_dict

bench/python/benchmark.py:569–909  ·  view source on GitHub ↗

Un-flattens (i.e expands) the data present in benchmark_dict and also calculates additions numbers.

(benchmark_dict, warmup_batches)

Source from the content-addressed store, hash-verified

567
568
569def unflatten_process_benchmark_dict(benchmark_dict, warmup_batches):
570 """
571 Un-flattens (i.e expands) the data present in benchmark_dict and also calculates
572 additions numbers.
573 """
574 # This function needs to do a few different things. Here is the overall flow:
575 #
576 # 1. It has to expand the keys
577 # so 'run_sample/pipeline/batch_0/preprocess.cvcuda' from NSYS json
578 # becomes the following nested dictionary:
579 # run_sample : {
580 # pipeline : {
581 # batch_0 : {
582 # preprocess.cvcuda : {"cpu_time": 0, "gpu_time": 0}
583 # }
584 # }
585 # }
586 #
587 # 2. Then it has to compute total of CPU and GPU times by aggregating those
588 # numbers at each level. In doing so, it has to account for warm-up batches
589 # i.e. batches whose timings should not be counted towards the total.
590 # run_sample : {
591 # pipeline : {
592 # batch_0 : {
593 # preprocess.cvcuda : {cpu_time: 0, gpu_time: 0}
594 # postprocess.cvcuda : {cpu_time: 0, gpu_time: 0}
595 # cpu_time : 0.0
596 # gpu_time : 0.0
597 # }
598 # }
599 # }
600 #
601 #
602 # 3. It also has to compute those times per frame/item. For this to happen, it needs
603 # the batch size information (i.e. how many items/frames were inside a batch) and
604 # also the information on which keys were "inside" a batch and which were not.
605 # These two pieces of information is taken from the benchmark.json
606 # pipeline : {
607 # batch_0 : {
608 # preprocess.cvcuda : {cpu_time: 0, gpu_time: 0}
609 # postprocess.cvcuda : {cpu_time: 0, gpu_time: 0}
610 # cpu_time : 0.0
611 # gpu_time : 0.0
612 # cpu_time_per_item: 0.0
613 # gpu_time_per_item: 0.0
614 # }
615 # }
616 # }
617 #
618 # 4. Finally, it computes various stats (e.g mean, median) of the timings from all
619 # the batches. In other words, it computes how much range X would take on an
620 # average when it is averaged across all the batches. To do this, we again use
621 # the information present inside benchmark.json and apply basic recursion math.
622 #
623
624 unfltten_data_dict = {} # This is where we will store un-flattened data for now.
625
626 # Maintains the total time of all warm-up batches.

Callers 1

benchmark_scriptFunction · 0.85

Calls 4

roundFunction · 0.85
recurse_gather_dictFunction · 0.85
recurse_calc_stats_dictFunction · 0.85

Tested by

no test coverage detected