Coverage for onnxcustom/cli/profiling.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.0.5, created at 2023-01-17 01:42 +0100

1""" 

2@file 

3@brief Command lines for profiling. 

4""" 

5from ..utils.nvprof2json import convert_trace_to_json 

6 

7 

8def nvprof2json(filename, output="", temporary_file="", verbose=1, 

9 fLOG=print): 

10 """ 

11 Converts traces produced by :epkg:`nvprof` and saved with 

12 format :epkg:`sqlite3` (extension `.sql`). 

13 

14 :param filename: filename 

15 :param output: output file, if left empty, the result is printed 

16 on the standard output 

17 :param temporary_file: if the file needs to be unzipped, 

18 this file will be created to be the unzipped file, 

19 it is not cleaned after the unzipping. 

20 :param verbose: verbosity 

21 :param fLOG: logging function 

22 :return: json (if output is None, the list of events otherwise) 

23 

24 .. cmdref:: 

25 :title: Converts a profile stored by nvprof into json 

26 :cmd: -m onnxcustom nvprof2json --help 

27 

28 The sqlite dump is generated with a command line similar to: 

29 

30 :: 

31 

32 nvprof -o gpu_profile.sql python plot_gpu_training.py 

33 

34 The command produces a json file following the *Trace Event Format*. 

35 """ 

36 verbose = int(verbose) 

37 res = convert_trace_to_json(filename, output, verbose=verbose, 

38 temporary_file=temporary_file, fLOG=fLOG) 

39 if output is None: # pragma: no cover 

40 fLOG(res)