Skip to content

Commit

Permalink
Speech sample report output ambiguity (openvinotoolkit#15135)
Browse files Browse the repository at this point in the history
* speech_sample: report output ambiguity

Ticket 100574

* Add missing ;, ambogous->ambiguous

* clang-format

* Fix help message
  • Loading branch information
Wovchena authored Jan 23, 2023
1 parent bd1808c commit dcb3b20
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
11 changes: 6 additions & 5 deletions samples/cpp/speech_sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,19 @@ Options:
-pc Optional. Enables per-layer performance report.
-q "<mode>" Optional. Input quantization mode: static (default), dynamic, or user (use with -sf).
-qb "<integer>" Optional. Weight bits for quantization: 8 or 16 (default)
-sf "<double>" Optional. User-specified input scale factor for quantization (use with -q user). If the network contains multiple inputs, provide scale factors by separating them with commas.
-bs "<integer>" Optional. Batch size 1-8
-layout "<string>" Optional. Prompts how network layouts should be treated by application.For example, \"input1[NCHW],input2[NC]\" or \"[NCHW]\" in case of one input size.
-sf "<double>" Optional. User-specified input scale factor for quantization (use with -q user). If the network contains multiple inputs, provide scale factors by separating them with commas. For example: <input_name1>:<sf1>,<input_name2>:<sf2> or just <sf> to be applied to all inputs
-bs "<integer>" Optional. Batch size 1-8 (default 1)
-r "<path>" Optional. Read reference score file or named layers with corresponding score files and compare scores. Example of usage for single file: <reference.ark> or <reference.npz>. Example of usage for named layers: Example of usage for named layers: <layer1:port_num>=<reference_file2.ark>,<layer2:port_num>=<reference_file2.ark>.
-rg "<path>" Read GNA model from file using path/filename provided (required if -m is missing).
-wg "<path>" Optional. Write GNA model to file using path/filename provided.
-we "<path>" Optional. Write GNA embedded model to file using path/filename provided.
-cw_l "<integer>" Optional. Number of frames for left context windows (default is 0). Works only with context window networks. If you use the cw_l or cw_r flag, then batch size argument is ignored.
-cw_r "<integer>" Optional. Number of frames for right context windows (default is 0). Works only with context window networks. If you use the cw_r or cw_l flag, then batch size argument is ignored.
-layout "<string>" Optional. Prompts how network layouts should be treated by application. For example, "input1[NCHW],input2[NC]" or "[NCHW]" in case of one input size.
-pwl_me "<double>" Optional. The maximum percent of error for PWL function.The value must be in <0, 100> range. The default value is 1.0.
-exec_target "<string>" Optional. Specify GNA execution target generation. May be one of GNA_TARGET_2_0, GNA_TARGET_3_0. By default, generation corresponds to the GNA HW available in the system or the latest fully supported generation by the software. See the GNA Plugin's GNA_EXEC_TARGET config option description.
-compile_target "<string>" Optional. Specify GNA compile target generation. May be one of GNA_TARGET_2_0, GNA_TARGET_3_0. By default, generation corresponds to the GNA HW available in the system or the latest fully supported generation by the software. See the GNA Plugin's GNA_COMPILE_TARGET config option description.
-memory_reuse_off Optional. Disables memory optimizations for compiled model.
Available target devices: CPU GNA GPU VPUX
```
Expand All @@ -132,9 +133,9 @@ mo --framework kaldi --input_model wsj_dnn5b.nnet --counts wsj_dnn5b.counts --re

The following pre-trained models are available:

- wsj_dnn5b_smbr
- rm_lstm4f
- rm_cnn4a_smbr
- rm_lstm4f
- wsj_dnn5b_smbr

All of them can be downloaded from [https://storage.openvinotoolkit.org/models_contrib/speech/2021.2](https://storage.openvinotoolkit.org/models_contrib/speech/2021.2).

Expand Down
12 changes: 10 additions & 2 deletions samples/cpp/speech_sample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,22 @@ int main(int argc, char* argv[]) {
if (output_name_files.size() != outputs.size() && outputs.size()) {
throw std::logic_error("The number of output files is not equal to the number of network outputs.");
}
count_file = output_name_files.empty() ? 1 : output_name_files.size();
count_file = output_name_files.size();
if (executableNet.outputs().size() > 1 && output_data.second.empty() && count_file == 1) {
throw std::logic_error("-o is ambiguous: the model has multiple outputs but only one file provided "
"without output name specification");
}
}
if (!reference_data.first.empty()) {
reference_name_files = convert_str_to_vector(reference_data.first);
if (reference_name_files.size() != outputs.size() && outputs.size()) {
throw std::logic_error("The number of reference files is not equal to the number of network outputs.");
}
count_file = reference_name_files.empty() ? 1 : reference_name_files.size();
count_file = reference_name_files.size();
if (executableNet.outputs().size() > 1 && reference_data.second.empty() && count_file == 1) {
throw std::logic_error("-r is ambiguous: the model has multiple outputs but only one file provided "
"without output name specification");
}
}
if (count_file > executableNet.outputs().size()) {
throw std::logic_error(
Expand Down
12 changes: 6 additions & 6 deletions samples/cpp/speech_sample/speech_sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ static const char custom_cpu_library_message[] = "Required for CPU plugin custom
/// @brief message for score output argument
static const char output_message[] =
"Optional. Output file name to save scores or Layer names with corresponding files names to save scores. Example "
"of usage for single file: <output.ark> or <output.npz>. Example of usage for named layers: Example of usage for "
"named layers: <layer1:port_num>=<output_file1.ark>,<layer2:port_num>=<output_file2.ark>.";
"of usage for single file: <output.ark> or <output.npz>. Example of usage for named layers: "
"<layer1:port_num>=<output_file1.ark>,<layer2:port_num>=<output_file2.ark>.";

/// @brief message for reference score file argument
static const char reference_score_message[] =
"Optional. Read reference score file or named layers with corresponding score files and compare scores. Example of "
"usage for single file: <reference.ark> or <reference.npz>. Example of usage for named layers: Example of usage "
"for named layers: <layer1:port_num>=<reference_file2.ark>,<layer2:port_num>=<reference_file2.ark>.";
"usage for single file: <reference.ark> or <reference.npz>. Example of usage for named layers: "
"<layer1:port_num>=<reference_file2.ark>,<layer2:port_num>=<reference_file2.ark>.";

/// @brief message for read GNA model argument
static const char read_gna_model_message[] =
Expand All @@ -89,7 +89,7 @@ static const char write_embedded_model_generation_message[] =

/// @brief message for quantization argument
static const char quantization_message[] =
"Optional. Input quantization mode: static (default), dynamic, or user (use with -sf).";
"Optional. Input quantization mode: static (default), dynamic, or user (use with -sf).";

/// @brief message for quantization bits argument
static const char quantization_bits_message[] = "Optional. Weight bits for quantization: 8 or 16 (default)";
Expand Down Expand Up @@ -222,7 +222,7 @@ static void show_usage() {
std::cout << " -pwl_me \"<double>\" " << pwl_max_error_percent_message << std::endl;
std::cout << " -exec_target \"<string>\" " << execution_target_message << std::endl;
std::cout << " -compile_target \"<string>\" " << compile_target_message << std::endl;
std::cout << " -memory_reuse_off " << memory_reuse_message << std::endl;
std::cout << " -memory_reuse_off " << memory_reuse_message << std::endl;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions samples/python/speech_sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ mo --framework kaldi --input_model wsj_dnn5b.nnet --counts wsj_dnn5b.counts --re

The following pre-trained models are available:

- wsj_dnn5b_smbr
- rm_lstm4f
- rm_cnn4a_smbr
- rm_lstm4f
- wsj_dnn5b_smbr

All of them can be downloaded from [https://storage.openvinotoolkit.org/models_contrib/speech/2021.2](https://storage.openvinotoolkit.org/models_contrib/speech/2021.2).

Expand Down

0 comments on commit dcb3b20

Please sign in to comment.