From d373d3574b26fecc64cd3837b74e755c7fee4587 Mon Sep 17 00:00:00 2001 From: "Koyanagi, Ken" Date: Wed, 14 Jul 2021 14:28:22 -0700 Subject: [PATCH 1/9] Adds perf counters, and scale factor args --- .../python/sample/speech_sample/README.md | 18 +++++--- .../python/sample/speech_sample/arg_parser.py | 5 +++ .../sample/speech_sample/speech_sample.py | 41 ++++++++++++++++--- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/README.md b/inference-engine/ie_bridges/python/sample/speech_sample/README.md index 2f7fd4323aa61d..9febe9caa926f2 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/README.md +++ b/inference-engine/ie_bridges/python/sample/speech_sample/README.md @@ -77,18 +77,18 @@ python /speech_sample.py -h Usage message: ``` -usage: speech_sample.py [-h] (-m MODEL | -rg IMPORT_GNA_MODEL) -i INPUT +usage: speech_sample.py [-h] (-m MODEL | -rg IMPORT_GNA_MODEL) -i INPUT [-o OUTPUT] [-r REFERENCE] [-d DEVICE] [-bs BATCH_SIZE] [-qb QUANTIZATION_BITS] - [-wg EXPORT_GNA_MODEL] [-iname INPUT_LAYERS] - [-oname OUTPUT_LAYERS] + [-sf SCALE_FACTOR] [-wg EXPORT_GNA_MODEL] [-pc] + [-a ARCH] [-iname INPUT_LAYERS] [-oname OUTPUT_LAYERS] optional arguments: -m MODEL, --model MODEL Path to an .xml file with a trained model (required if -rg is missing). -rg IMPORT_GNA_MODEL, --import_gna_model IMPORT_GNA_MODEL - Read GNA model from file using path/filename provided + Read GNA model from file using path/filename provided (required if -m is missing). Options: @@ -96,7 +96,8 @@ Options: -i INPUT, --input INPUT Required. Path to an input file (.ark or .npz). -o OUTPUT, --output OUTPUT - Optional. Output file name to save inference results (.ark or .npz). + Optional. Output file name to save inference results + (.ark or .npz). -r REFERENCE, --reference REFERENCE Optional. Read reference score file and compare scores. @@ -113,9 +114,16 @@ Options: -qb QUANTIZATION_BITS, --quantization_bits QUANTIZATION_BITS Optional. Weight bits for quantization: 8 or 16 (default 16). + -sf SCALE_FACTOR, --scale_factor SCALE_FACTOR + Optional. Input scale factor for quantization. -wg EXPORT_GNA_MODEL, --export_gna_model EXPORT_GNA_MODEL Optional. Write GNA model to file using path/filename provided. + -pc, --performance_counter + Optional. Enables performance report. (specify -a to + ensure arch accurate results) + -a ARCH, --arch ARCH Optional. Specify architecture. CORE, ATOM with + combination of -pc -iname INPUT_LAYERS, --input_layers INPUT_LAYERS Optional. Layer names for input blobs. The names are separated with ",". Allows to change the order of diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py index cfc20dfb42590c..66d7f853c0e83b 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py @@ -28,10 +28,15 @@ def parse_args() -> argparse.Namespace: args.add_argument('-bs', '--batch_size', default=1, type=int, help='Optional. Batch size 1-8 (default 1).') args.add_argument('-qb', '--quantization_bits', default=16, type=int, help='Optional. Weight bits for quantization: 8 or 16 (default 16).') + args.add_argument('-sf', '--scale_factor', type=float, help='Optional. Input scale factor for quantization.') args.add_argument('-wg', '--export_gna_model', type=str, help='Optional. Write GNA model to file using path/filename provided.') args.add_argument('-we', '--export_embedded_gna_model', type=str, help=argparse.SUPPRESS) args.add_argument('-we_gen', '--embedded_gna_configuration', default='GNA1', type=str, help=argparse.SUPPRESS) + args.add_argument('-pc', '--performance_counter', action='store_true', + help='Optional. Enables performance report. (specify -a to ensure arch accurate results)') + args.add_argument('-a', '--arch', default="CORE", type=str, help='Optional. Specify architecture. CORE, ATOM' + ' with combination of -pc') args.add_argument('-iname', '--input_layers', type=str, help='Optional. Layer names for input blobs. The names are separated with ",". ' 'Allows to change the order of input layers for -i flag. Example: Input1,Input2') diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py index 8019746d177088..dcc0e1b6572a4a 100755 --- a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py @@ -137,15 +137,21 @@ def main(): else: utterances = read_utterance_file(args.input.split(',')[0]) key = sorted(utterances)[0] - scale_factor = get_scale_factor(utterances[key]) - log.info(f'Using scale factor of {scale_factor:.7f} calculated from first utterance.') - - plugin_config['GNA_SCALE_FACTOR'] = str(scale_factor) + if args.scale_factor: + log.info('Using user defined scale factor of %s', str(args.scale_factor)) + plugin_config['GNA_SCALE_FACTOR'] = str(args.scale_factor) + else: + scale_factor = get_scale_factor(utterances[key]) + log.info(f'Using scale factor of {scale_factor:.7f} calculated from first utterance.') + plugin_config['GNA_SCALE_FACTOR'] = str(scale_factor) if args.export_embedded_gna_model: plugin_config['GNA_FIRMWARE_MODEL_IMAGE'] = args.export_embedded_gna_model plugin_config['GNA_FIRMWARE_MODEL_IMAGE_GENERATION'] = args.embedded_gna_configuration + if args.performance_counter: + plugin_config['PERF_COUNT'] = 'YES' + device_str = f'HETERO:{",".join(devices)}' if 'HETERO' in args.device else devices[0] log.info('Loading the model to the plugin') @@ -187,7 +193,11 @@ def main(): log.info(f'Exported GNA embedded model to file {args.export_embedded_gna_model}') log.info(f'GNA embedded model export done for GNA generation {args.embedded_gna_configuration}') return 0 - + + if args.arch: + if args.arch not in ("CORE", "ARCH"): + log.error('The architectuer argument only accepts CORE or ARCH') + sys.exit(-3) # ---------------------------Step 5. Create infer request-------------------------------------------------------------- # load_network() method of the IECore class with a specified number of requests (default 1) returns an ExecutableNetwork # instance which stores infer requests. So you already created Infer requests in the previous step. @@ -208,6 +218,7 @@ def main(): log.info('Starting inference in synchronous mode') results = {blob_name: {} for blob_name in output_blobs} infer_times = [] + perf_counters = [] for key in sorted(input_data): start_infer_time = default_timer() @@ -222,7 +233,9 @@ def main(): for blob_name in result.keys(): results[blob_name][key] = result[blob_name] + infer_times.append(default_timer() - start_infer_time) + perf_counters.append(exec_net.requests[0].get_perf_counts()) # ---------------------------Step 8. Process output-------------------------------------------------------------------- for blob_name in output_blobs: @@ -235,6 +248,24 @@ def main(): if args.reference: compare_with_reference(results[blob_name][key], references[blob_name][key]) + if args.performance_counter: + pc = perf_counters[i] + total_cycles = int(pc["1.1 Total scoring time in HW"]["real_time"]) + stall_cycles = int(pc["1.2 Stall scoring time in HW"]["real_time"]) + active_cycles = total_cycles - stall_cycles + frequency = 10**6 + if args.arch == "CORE": + frequency *= 400 + else: + frequency *= 200 + total_inference_time = total_cycles/frequency + active_time = active_cycles/frequency + stall_time = stall_cycles/frequency + print("\nPerformance Statistics of GNA Hardware") + print(" Total Inference Time: " + str(total_inference_time * 1000) + " ms") + print(" Active Time: " + str(active_time * 1000) + " ms") + print(" Stall Time: " + str(stall_time * 1000) + " ms\n") + log.info('') log.info(f'Total sample time: {sum(infer_times) * 1000:.2f}ms') From 03d498691c10919098d3cf1df4552365e7af951f Mon Sep 17 00:00:00 2001 From: "Koyanagi, Ken" Date: Thu, 15 Jul 2021 17:35:42 -0700 Subject: [PATCH 2/9] Adding defined choices for arch type for -a/--arch option --- .../ie_bridges/python/sample/speech_sample/arg_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py index 66d7f853c0e83b..09217c34862381 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py @@ -35,8 +35,8 @@ def parse_args() -> argparse.Namespace: args.add_argument('-we_gen', '--embedded_gna_configuration', default='GNA1', type=str, help=argparse.SUPPRESS) args.add_argument('-pc', '--performance_counter', action='store_true', help='Optional. Enables performance report. (specify -a to ensure arch accurate results)') - args.add_argument('-a', '--arch', default="CORE", type=str, help='Optional. Specify architecture. CORE, ATOM' - ' with combination of -pc') + args.add_argument('-a', '--arch', default="CORE", type=str.upper, choices=['CORE', 'ATOM'], + help='Optional. Specify architecture. CORE, ATOM with combination of -pc') args.add_argument('-iname', '--input_layers', type=str, help='Optional. Layer names for input blobs. The names are separated with ",". ' 'Allows to change the order of input layers for -i flag. Example: Input1,Input2') From 8659a08e8f9134aef0d92f965105deb8458a1422 Mon Sep 17 00:00:00 2001 From: "Koyanagi, Ken" Date: Thu, 15 Jul 2021 17:36:10 -0700 Subject: [PATCH 3/9] changing print to logger, frequencies are now global consts --- .../sample/speech_sample/speech_sample.py | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py index dcc0e1b6572a4a..6b61cdae6e8be5 100755 --- a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py @@ -12,6 +12,9 @@ from file_options import read_utterance_file, write_utterance_file from openvino.inference_engine import ExecutableNetwork, IECore +# Operating Frequency for GNA HW devices for Core and Atom architecture +GNA_CORE_FREQUENCY = 400 +GNA_ATOM_FREQUENCY = 200 def get_scale_factor(matrix: np.ndarray) -> float: """Get scale factor for quantization using utterance matrix""" @@ -138,7 +141,7 @@ def main(): utterances = read_utterance_file(args.input.split(',')[0]) key = sorted(utterances)[0] if args.scale_factor: - log.info('Using user defined scale factor of %s', str(args.scale_factor)) + log.info(f'Using user defined scale factor of {args.scale_factor:.7f}.') plugin_config['GNA_SCALE_FACTOR'] = str(args.scale_factor) else: scale_factor = get_scale_factor(utterances[key]) @@ -194,10 +197,6 @@ def main(): log.info(f'GNA embedded model export done for GNA generation {args.embedded_gna_configuration}') return 0 - if args.arch: - if args.arch not in ("CORE", "ARCH"): - log.error('The architectuer argument only accepts CORE or ARCH') - sys.exit(-3) # ---------------------------Step 5. Create infer request-------------------------------------------------------------- # load_network() method of the IECore class with a specified number of requests (default 1) returns an ExecutableNetwork # instance which stores infer requests. So you already created Infer requests in the previous step. @@ -255,16 +254,16 @@ def main(): active_cycles = total_cycles - stall_cycles frequency = 10**6 if args.arch == "CORE": - frequency *= 400 + frequency *= GNA_CORE_FREQUENCY else: - frequency *= 200 + frequency *= GNA_ATOM_FREQUENCY total_inference_time = total_cycles/frequency active_time = active_cycles/frequency stall_time = stall_cycles/frequency - print("\nPerformance Statistics of GNA Hardware") - print(" Total Inference Time: " + str(total_inference_time * 1000) + " ms") - print(" Active Time: " + str(active_time * 1000) + " ms") - print(" Stall Time: " + str(stall_time * 1000) + " ms\n") + log.info(f"\nPerformance Statistics of GNA Hardware") + log.info(f" Total Inference Time: " + str(total_inference_time * 1000) + " ms") + log.info(f" Active Time: " + str(active_time * 1000) + " ms") + log.info(f" Stall Time: " + str(stall_time * 1000) + " ms\n") log.info('') From 4689c8615bbe13fbba03856ee2159581f05d60fe Mon Sep 17 00:00:00 2001 From: "Koyanagi, Ken" Date: Thu, 15 Jul 2021 22:11:06 -0700 Subject: [PATCH 4/9] change to log info formatting --- .../python/sample/speech_sample/speech_sample.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py index 6b61cdae6e8be5..82e875f470c19c 100755 --- a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py @@ -260,10 +260,11 @@ def main(): total_inference_time = total_cycles/frequency active_time = active_cycles/frequency stall_time = stall_cycles/frequency - log.info(f"\nPerformance Statistics of GNA Hardware") - log.info(f" Total Inference Time: " + str(total_inference_time * 1000) + " ms") - log.info(f" Active Time: " + str(active_time * 1000) + " ms") - log.info(f" Stall Time: " + str(stall_time * 1000) + " ms\n") + log.info('') + log.info(f"Performance Statistics of GNA Hardware") + log.info(f" Total Inference Time: {(total_inference_time * 1000):.4f} ms") + log.info(f" Active Time: {(active_time * 1000):.4f} ms") + log.info(f" Stall Time: {(stall_time * 1000):.4f} ms") log.info('') From e1903efef420ca7434195b530a43934d964da105 Mon Sep 17 00:00:00 2001 From: dpigasin Date: Tue, 24 Aug 2021 16:31:24 +0300 Subject: [PATCH 5/9] Fix style issues --- .../python/sample/speech_sample/README.md | 25 +++++---- .../python/sample/speech_sample/arg_parser.py | 11 ++-- .../sample/speech_sample/speech_sample.py | 56 +++++++++---------- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/README.md b/inference-engine/ie_bridges/python/sample/speech_sample/README.md index 9febe9caa926f2..6cbc99bbf93107 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/README.md +++ b/inference-engine/ie_bridges/python/sample/speech_sample/README.md @@ -77,26 +77,27 @@ python /speech_sample.py -h Usage message: ``` -usage: speech_sample.py [-h] (-m MODEL | -rg IMPORT_GNA_MODEL) -i INPUT +usage: speech_sample.py [-h] (-m MODEL | -rg IMPORT_GNA_MODEL) -i INPUT [-o OUTPUT] [-r REFERENCE] [-d DEVICE] [-bs BATCH_SIZE] [-qb QUANTIZATION_BITS] - [-sf SCALE_FACTOR] [-wg EXPORT_GNA_MODEL] [-pc] - [-a ARCH] [-iname INPUT_LAYERS] [-oname OUTPUT_LAYERS] + [-sf SCALE_FACTOR] [-wg EXPORT_GNA_MODEL] [-pc] + [-a {CORE,ATOM}] [-iname INPUT_LAYERS] + [-oname OUTPUT_LAYERS] optional arguments: -m MODEL, --model MODEL Path to an .xml file with a trained model (required if -rg is missing). -rg IMPORT_GNA_MODEL, --import_gna_model IMPORT_GNA_MODEL - Read GNA model from file using path/filename provided + Read GNA model from file using path/filename provided (required if -m is missing). Options: -h, --help Show this help message and exit. -i INPUT, --input INPUT - Required. Path to an input file (.ark or .npz). + Required. Path to an input file (.ark or .npz). -o OUTPUT, --output OUTPUT - Optional. Output file name to save inference results + Optional. Output file name to save inference results (.ark or .npz). -r REFERENCE, --reference REFERENCE Optional. Read reference score file and compare @@ -115,15 +116,17 @@ Options: Optional. Weight bits for quantization: 8 or 16 (default 16). -sf SCALE_FACTOR, --scale_factor SCALE_FACTOR - Optional. Input scale factor for quantization. + Optional. User-specified input scale factor for + quantization. -wg EXPORT_GNA_MODEL, --export_gna_model EXPORT_GNA_MODEL Optional. Write GNA model to file using path/filename provided. -pc, --performance_counter - Optional. Enables performance report. (specify -a to - ensure arch accurate results) - -a ARCH, --arch ARCH Optional. Specify architecture. CORE, ATOM with - combination of -pc + Optional. Enables performance report (specify -a to + ensure arch accurate results). + -a {CORE,ATOM}, --arch {CORE,ATOM} + Optional. Specify a architecture. CORE, ATOM with + combination of -pc. -iname INPUT_LAYERS, --input_layers INPUT_LAYERS Optional. Layer names for input blobs. The names are separated with ",". Allows to change the order of diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py index 09217c34862381..d00bcc65854594 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py @@ -28,15 +28,16 @@ def parse_args() -> argparse.Namespace: args.add_argument('-bs', '--batch_size', default=1, type=int, help='Optional. Batch size 1-8 (default 1).') args.add_argument('-qb', '--quantization_bits', default=16, type=int, help='Optional. Weight bits for quantization: 8 or 16 (default 16).') - args.add_argument('-sf', '--scale_factor', type=float, help='Optional. Input scale factor for quantization.') + args.add_argument('-sf', '--scale_factor', type=float, + help='Optional. User-specified input scale factor for quantization.') args.add_argument('-wg', '--export_gna_model', type=str, help='Optional. Write GNA model to file using path/filename provided.') args.add_argument('-we', '--export_embedded_gna_model', type=str, help=argparse.SUPPRESS) args.add_argument('-we_gen', '--embedded_gna_configuration', default='GNA1', type=str, help=argparse.SUPPRESS) - args.add_argument('-pc', '--performance_counter', action='store_true', - help='Optional. Enables performance report. (specify -a to ensure arch accurate results)') - args.add_argument('-a', '--arch', default="CORE", type=str.upper, choices=['CORE', 'ATOM'], - help='Optional. Specify architecture. CORE, ATOM with combination of -pc') + args.add_argument('-pc', '--performance_counter', action='store_true', + help='Optional. Enables performance report (specify -a to ensure arch accurate results).') + args.add_argument('-a', '--arch', default='CORE', type=str.upper, choices=['CORE', 'ATOM'], + help='Optional. Specify a architecture. CORE, ATOM with combination of -pc.') args.add_argument('-iname', '--input_layers', type=str, help='Optional. Layer names for input blobs. The names are separated with ",". ' 'Allows to change the order of input layers for -i flag. Example: Input1,Input2') diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py index 82e875f470c19c..0a86d467742b9c 100755 --- a/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/speech_sample.py @@ -16,6 +16,7 @@ GNA_CORE_FREQUENCY = 400 GNA_ATOM_FREQUENCY = 200 + def get_scale_factor(matrix: np.ndarray) -> float: """Get scale factor for quantization using utterance matrix""" # Max to find scale factor @@ -134,26 +135,25 @@ def main(): plugin_config['GNA_DEVICE_MODE'] = gna_device_mode plugin_config['GNA_PRECISION'] = f'I{args.quantization_bits}' - # Get a GNA scale factor + # Set a GNA scale factor if args.import_gna_model: log.info(f'Using scale factor from the imported GNA model: {args.import_gna_model}') + elif args.scale_factor: + log.info(f'Using scale factor of {args.scale_factor:.7f} specified by user.') + plugin_config['GNA_SCALE_FACTOR'] = str(args.scale_factor) else: utterances = read_utterance_file(args.input.split(',')[0]) key = sorted(utterances)[0] - if args.scale_factor: - log.info(f'Using user defined scale factor of {args.scale_factor:.7f}.') - plugin_config['GNA_SCALE_FACTOR'] = str(args.scale_factor) - else: - scale_factor = get_scale_factor(utterances[key]) - log.info(f'Using scale factor of {scale_factor:.7f} calculated from first utterance.') - plugin_config['GNA_SCALE_FACTOR'] = str(scale_factor) + scale_factor = get_scale_factor(utterances[key]) + log.info(f'Using scale factor of {scale_factor:.7f} calculated from first utterance.') + plugin_config['GNA_SCALE_FACTOR'] = str(scale_factor) if args.export_embedded_gna_model: plugin_config['GNA_FIRMWARE_MODEL_IMAGE'] = args.export_embedded_gna_model plugin_config['GNA_FIRMWARE_MODEL_IMAGE_GENERATION'] = args.embedded_gna_configuration if args.performance_counter: - plugin_config['PERF_COUNT'] = 'YES' + plugin_config['PERF_COUNT'] = 'YES' device_str = f'HETERO:{",".join(devices)}' if 'HETERO' in args.device else devices[0] @@ -196,7 +196,7 @@ def main(): log.info(f'Exported GNA embedded model to file {args.export_embedded_gna_model}') log.info(f'GNA embedded model export done for GNA generation {args.embedded_gna_configuration}') return 0 - + # ---------------------------Step 5. Create infer request-------------------------------------------------------------- # load_network() method of the IECore class with a specified number of requests (default 1) returns an ExecutableNetwork # instance which stores infer requests. So you already created Infer requests in the previous step. @@ -232,7 +232,6 @@ def main(): for blob_name in result.keys(): results[blob_name][key] = result[blob_name] - infer_times.append(default_timer() - start_infer_time) perf_counters.append(exec_net.requests[0].get_perf_counts()) @@ -248,23 +247,24 @@ def main(): compare_with_reference(results[blob_name][key], references[blob_name][key]) if args.performance_counter: - pc = perf_counters[i] - total_cycles = int(pc["1.1 Total scoring time in HW"]["real_time"]) - stall_cycles = int(pc["1.2 Stall scoring time in HW"]["real_time"]) - active_cycles = total_cycles - stall_cycles - frequency = 10**6 - if args.arch == "CORE": - frequency *= GNA_CORE_FREQUENCY - else: - frequency *= GNA_ATOM_FREQUENCY - total_inference_time = total_cycles/frequency - active_time = active_cycles/frequency - stall_time = stall_cycles/frequency - log.info('') - log.info(f"Performance Statistics of GNA Hardware") - log.info(f" Total Inference Time: {(total_inference_time * 1000):.4f} ms") - log.info(f" Active Time: {(active_time * 1000):.4f} ms") - log.info(f" Stall Time: {(stall_time * 1000):.4f} ms") + if 'GNA' in args.device: + pc = perf_counters[i] + total_cycles = int(pc['1.1 Total scoring time in HW']['real_time']) + stall_cycles = int(pc['1.2 Stall scoring time in HW']['real_time']) + active_cycles = total_cycles - stall_cycles + frequency = 10**6 + if args.arch == 'CORE': + frequency *= GNA_CORE_FREQUENCY + else: + frequency *= GNA_ATOM_FREQUENCY + total_inference_time = total_cycles / frequency + active_time = active_cycles / frequency + stall_time = stall_cycles / frequency + log.info('') + log.info('Performance Statistics of GNA Hardware') + log.info(f' Total Inference Time: {(total_inference_time * 1000):.4f} ms') + log.info(f' Active Time: {(active_time * 1000):.4f} ms') + log.info(f' Stall Time: {(stall_time * 1000):.4f} ms') log.info('') From ba072c01d332ea6e7b96a725cea16a972a1b9bc7 Mon Sep 17 00:00:00 2001 From: Kate Generalova Date: Fri, 3 Sep 2021 13:13:07 +0300 Subject: [PATCH 6/9] doc: Update inference-engine/ie_bridges/python/sample/speech_sample/README.md --- .../ie_bridges/python/sample/speech_sample/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/README.md b/inference-engine/ie_bridges/python/sample/speech_sample/README.md index 6cbc99bbf93107..1152eb3c3f2259 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/README.md +++ b/inference-engine/ie_bridges/python/sample/speech_sample/README.md @@ -116,7 +116,7 @@ Options: Optional. Weight bits for quantization: 8 or 16 (default 16). -sf SCALE_FACTOR, --scale_factor SCALE_FACTOR - Optional. User-specified input scale factor for + Optional. The user-specified input scale factor for quantization. -wg EXPORT_GNA_MODEL, --export_gna_model EXPORT_GNA_MODEL Optional. Write GNA model to file using path/filename From 03eecfdc165e5941eb33d0beefae0e1ab9dc5e40 Mon Sep 17 00:00:00 2001 From: Kate Generalova Date: Fri, 3 Sep 2021 13:13:15 +0300 Subject: [PATCH 7/9] doc: Update inference-engine/ie_bridges/python/sample/speech_sample/README.md --- .../ie_bridges/python/sample/speech_sample/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/README.md b/inference-engine/ie_bridges/python/sample/speech_sample/README.md index 1152eb3c3f2259..54403416bc4ace 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/README.md +++ b/inference-engine/ie_bridges/python/sample/speech_sample/README.md @@ -125,7 +125,7 @@ Options: Optional. Enables performance report (specify -a to ensure arch accurate results). -a {CORE,ATOM}, --arch {CORE,ATOM} - Optional. Specify a architecture. CORE, ATOM with + Optional. Specify architecture. CORE, ATOM with the combination of -pc. -iname INPUT_LAYERS, --input_layers INPUT_LAYERS Optional. Layer names for input blobs. The names are From 0d12155bca2645860d85ebb8d6923481bbf714e2 Mon Sep 17 00:00:00 2001 From: Kate Generalova Date: Fri, 3 Sep 2021 13:13:27 +0300 Subject: [PATCH 8/9] doc: Update inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py --- .../ie_bridges/python/sample/speech_sample/arg_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py index d00bcc65854594..18e43b09d60a33 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py @@ -29,7 +29,7 @@ def parse_args() -> argparse.Namespace: args.add_argument('-qb', '--quantization_bits', default=16, type=int, help='Optional. Weight bits for quantization: 8 or 16 (default 16).') args.add_argument('-sf', '--scale_factor', type=float, - help='Optional. User-specified input scale factor for quantization.') + help='Optional. The user-specified input scale factor for quantization.') args.add_argument('-wg', '--export_gna_model', type=str, help='Optional. Write GNA model to file using path/filename provided.') args.add_argument('-we', '--export_embedded_gna_model', type=str, help=argparse.SUPPRESS) From a42eb59855b7b5892e32990c3cceb1b0a0df28d5 Mon Sep 17 00:00:00 2001 From: Kate Generalova Date: Fri, 3 Sep 2021 13:13:35 +0300 Subject: [PATCH 9/9] doc: Update inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py --- .../ie_bridges/python/sample/speech_sample/arg_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py index 18e43b09d60a33..1d2ad5c7d71a7f 100644 --- a/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py +++ b/inference-engine/ie_bridges/python/sample/speech_sample/arg_parser.py @@ -37,7 +37,7 @@ def parse_args() -> argparse.Namespace: args.add_argument('-pc', '--performance_counter', action='store_true', help='Optional. Enables performance report (specify -a to ensure arch accurate results).') args.add_argument('-a', '--arch', default='CORE', type=str.upper, choices=['CORE', 'ATOM'], - help='Optional. Specify a architecture. CORE, ATOM with combination of -pc.') + help='Optional. Specify architecture. CORE, ATOM with the combination of -pc.') args.add_argument('-iname', '--input_layers', type=str, help='Optional. Layer names for input blobs. The names are separated with ",". ' 'Allows to change the order of input layers for -i flag. Example: Input1,Input2')