Update samples style (#6998)
* Align clang config with IE * Apply code style * Update code style for c samples * Fixed style for c samples
This commit is contained in:
parent
c986ce09ce
commit
b1f009d470
@ -1,6 +1,7 @@
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
UseTab: Never
|
||||
ColumnLimit: 120
|
||||
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
@ -8,18 +9,20 @@ Standard: Cpp11
|
||||
AccessModifierOffset: -4
|
||||
AlignConsecutiveMacros: true
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
ColumnLimit: 160
|
||||
# Specialize this comment pragma in order to avoid changes in SEA copyrights
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
CommentPragmas: '^#'
|
||||
DerivePointerAlignment: false
|
||||
FixNamespaceComments: true
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: BeforeHash
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: false
|
||||
IndentPPDirectives: AfterHash
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- FOREACH_CHILD
|
||||
|
@ -24,8 +24,8 @@ int image_add_rectangles(c_mat_t* img, rectangle_t rects[], int classes[], int n
|
||||
|
||||
#else
|
||||
|
||||
#include <algorithm>
|
||||
#include <opencv2/opencv.hpp>
|
||||
# include <algorithm>
|
||||
# include <opencv2/opencv.hpp>
|
||||
|
||||
int image_read(const char* img_path, c_mat_t* img) {
|
||||
if (img_path == nullptr || img == nullptr) {
|
||||
@ -102,9 +102,11 @@ int image_free(c_mat_t* img) {
|
||||
int image_add_rectangles(c_mat_t* img, rectangle_t rects[], int classes[], int num, int thickness) {
|
||||
int colors_num = 21;
|
||||
color_t colors[21] = {// colors to be used for bounding boxes
|
||||
{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190}, {153, 153, 153}, {30, 170, 250},
|
||||
{0, 220, 220}, {35, 142, 107}, {152, 251, 152}, {180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0},
|
||||
{70, 0, 0}, {100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111}, {81, 0, 81}};
|
||||
{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190},
|
||||
{153, 153, 153}, {30, 170, 250}, {0, 220, 220}, {35, 142, 107}, {152, 251, 152},
|
||||
{180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0}, {70, 0, 0},
|
||||
{100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111},
|
||||
{81, 0, 81}};
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
int x = rects[i].x_min;
|
||||
|
@ -6,23 +6,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define OPENCV_C_EXTERN extern "C"
|
||||
# define OPENCV_C_EXTERN extern "C"
|
||||
#else
|
||||
#define OPENCV_C_EXTERN
|
||||
# define OPENCV_C_EXTERN
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ < 4)
|
||||
#define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __VA_ARGS__
|
||||
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __VA_ARGS__
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
#ifdef opencv_c_wrapper_EXPORTS
|
||||
#define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __declspec(dllexport) __VA_ARGS__ __cdecl
|
||||
#else
|
||||
#define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __declspec(dllimport) __VA_ARGS__ __cdecl
|
||||
#endif
|
||||
#else
|
||||
#define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __attribute__((visibility("default"))) __VA_ARGS__
|
||||
#endif
|
||||
# if defined(_WIN32)
|
||||
# ifdef opencv_c_wrapper_EXPORTS
|
||||
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __declspec(dllexport) __VA_ARGS__ __cdecl
|
||||
# else
|
||||
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __declspec(dllimport) __VA_ARGS__ __cdecl
|
||||
# endif
|
||||
# else
|
||||
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __attribute__((visibility("default"))) __VA_ARGS__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -6,43 +6,43 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN_UNDEF
|
||||
#endif
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# endif
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#define NOMINMAX_UNDEF
|
||||
#endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# define NOMINMAX_UNDEF
|
||||
# endif
|
||||
|
||||
#if defined(_M_IX86) && !defined(_X86_) && !defined(_AMD64_)
|
||||
#define _X86_
|
||||
#endif
|
||||
# if defined(_M_IX86) && !defined(_X86_) && !defined(_AMD64_)
|
||||
# define _X86_
|
||||
# endif
|
||||
|
||||
#if defined(_M_X64) && !defined(_X86_) && !defined(_AMD64_)
|
||||
#define _AMD64_
|
||||
#endif
|
||||
# if defined(_M_X64) && !defined(_X86_) && !defined(_AMD64_)
|
||||
# define _AMD64_
|
||||
# endif
|
||||
|
||||
#if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
#define _ARM_
|
||||
#endif
|
||||
# if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
# define _ARM_
|
||||
# endif
|
||||
|
||||
#if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
#define _ARM64_
|
||||
#endif
|
||||
# if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
# define _ARM64_
|
||||
# endif
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
#include <string.h>
|
||||
#include <windef.h>
|
||||
#include <fileapi.h>
|
||||
#include <Winbase.h>
|
||||
#include <sys/stat.h>
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
|
||||
// Copied from linux libc sys/stat.h:
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
// Copied from linux libc sys/stat.h:
|
||||
# define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
|
||||
/// @brief structure to store directory names
|
||||
typedef struct dirent {
|
||||
@ -171,19 +171,19 @@ static void closedir(DIR* dp) {
|
||||
free(dp);
|
||||
}
|
||||
|
||||
#ifdef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
#endif
|
||||
# ifdef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# undef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# endif
|
||||
|
||||
#ifdef NOMINMAX_UNDEF
|
||||
#undef NOMINMAX_UNDEF
|
||||
#undef NOMINMAX
|
||||
#endif
|
||||
# ifdef NOMINMAX_UNDEF
|
||||
# undef NOMINMAX_UNDEF
|
||||
# undef NOMINMAX
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
# include <dirent.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
#endif
|
@ -12,9 +12,9 @@
|
||||
#include "object_detection_sample_ssd.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "c_w_dirent.h"
|
||||
# include "c_w_dirent.h"
|
||||
#else
|
||||
#include <dirent.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#define MAX_IMAGES 20
|
||||
@ -346,7 +346,10 @@ int main(int argc, char** argv) {
|
||||
goto err;
|
||||
for (i = 0; i < ver.num_vers; ++i) {
|
||||
printf(" %s\n", ver.versions[i].device_name);
|
||||
printf(" %s version ......... %zu.%zu\n", ver.versions[i].description, ver.versions[i].major, ver.versions[i].minor);
|
||||
printf(" %s version ......... %zu.%zu\n",
|
||||
ver.versions[i].description,
|
||||
ver.versions[i].major,
|
||||
ver.versions[i].minor);
|
||||
printf(" Build ......... %s\n", ver.versions[i].build_number);
|
||||
}
|
||||
ie_core_versions_free(&ver);
|
||||
@ -360,7 +363,8 @@ int main(int argc, char** argv) {
|
||||
printf("%sCustom extension loaded: %s\n", info, custom_ex_library_msg);
|
||||
}
|
||||
|
||||
if (custom_plugin_cfg_msg && (strcmp(device_name, "GPU") == 0 || strcmp(device_name, "MYRIAD") == 0 || strcmp(device_name, "HDDL") == 0)) {
|
||||
if (custom_plugin_cfg_msg &&
|
||||
(strcmp(device_name, "GPU") == 0 || strcmp(device_name, "MYRIAD") == 0 || strcmp(device_name, "HDDL") == 0)) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie_config_t cfg = {"CONFIG_FILE", custom_plugin_cfg_msg, NULL};
|
||||
@ -480,7 +484,12 @@ int main(int argc, char** argv) {
|
||||
for (j = 0; j < resized_img.mat_data_size; ++j)
|
||||
resized_img.mat_data[j] = img.mat_data[j];
|
||||
} else {
|
||||
printf("%sImage is resized from (%d, %d) to (%zu, %zu)\n", warn, img.mat_width, img.mat_height, input_width, input_height);
|
||||
printf("%sImage is resized from (%d, %d) to (%zu, %zu)\n",
|
||||
warn,
|
||||
img.mat_width,
|
||||
img.mat_height,
|
||||
input_width,
|
||||
input_height);
|
||||
|
||||
if (image_resize(&img, &resized_img, (int)input_width, (int)input_height) == -1) {
|
||||
printf("%sImage %s cannot be resized!\n", warn, file_paths[i]);
|
||||
@ -623,7 +632,8 @@ int main(int argc, char** argv) {
|
||||
for (ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in bytes
|
||||
* **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] = images[image_id].mat_data[pid * num_channels + ch];
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
images[image_id].mat_data[pid * num_channels + ch];
|
||||
}
|
||||
}
|
||||
image_free(&images[image_id]);
|
||||
@ -704,7 +714,15 @@ int main(int argc, char** argv) {
|
||||
int xmax = (int)(detection[curProposal * objectSize + 5] * originalImages[image_id].mat_width);
|
||||
int ymax = (int)(detection[curProposal * objectSize + 6] * originalImages[image_id].mat_height);
|
||||
|
||||
printf("[%d, %d] element, prob = %f (%d, %d)-(%d, %d) batch id : %d", curProposal, label, confidence, xmin, ymin, xmax, ymax, image_id);
|
||||
printf("[%d, %d] element, prob = %f (%d, %d)-(%d, %d) batch id : %d",
|
||||
curProposal,
|
||||
label,
|
||||
confidence,
|
||||
xmin,
|
||||
ymin,
|
||||
xmax,
|
||||
ymax,
|
||||
image_id);
|
||||
|
||||
if (confidence > 0.5) {
|
||||
/** Drawing only objects with >50% probability **/
|
||||
@ -722,7 +740,11 @@ int main(int argc, char** argv) {
|
||||
int batch_id;
|
||||
for (batch_id = 0; batch_id < batchSize; ++batch_id) {
|
||||
if (object_num[batch_id] > 0) {
|
||||
image_add_rectangles(&originalImages[batch_id], boxes[batch_id], classes[batch_id], object_num[batch_id], 2);
|
||||
image_add_rectangles(&originalImages[batch_id],
|
||||
boxes[batch_id],
|
||||
classes[batch_id],
|
||||
object_num[batch_id],
|
||||
2);
|
||||
}
|
||||
const char* out = "out_";
|
||||
char str_num[16] = {0};
|
||||
|
@ -16,14 +16,16 @@ static const char* model_message = "Required. Path to an .xml file with a traine
|
||||
static const char* image_message = "Required. Path to one or more images or folder with images.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char* target_device_message = "Optional. Specify the target device to infer. "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma-separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
static const char* target_device_message =
|
||||
"Optional. Specify the target device to infer. "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma-separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for plugin custom kernels desc
|
||||
static const char* custom_plugin_config_message = "Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
"Absolute path to the .xml config file with the kernels descriptions.";
|
||||
static const char* custom_plugin_config_message =
|
||||
"Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
"Absolute path to the .xml config file with the kernels descriptions.";
|
||||
|
||||
/// @brief message for user extension library argument
|
||||
static const char* custom_ex_library_message = "Required for CPU plugin custom layers. "
|
||||
|
@ -1,6 +1,7 @@
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
UseTab: Never
|
||||
ColumnLimit: 120
|
||||
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
@ -8,18 +9,20 @@ Standard: Cpp11
|
||||
AccessModifierOffset: -4
|
||||
AlignConsecutiveMacros: true
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
ColumnLimit: 160
|
||||
# Specialize this comment pragma in order to avoid changes in SEA copyrights
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
CommentPragmas: '^#'
|
||||
DerivePointerAlignment: false
|
||||
FixNamespaceComments: true
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: BeforeHash
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: false
|
||||
IndentPPDirectives: AfterHash
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- FOREACH_CHILD
|
||||
|
@ -14,28 +14,33 @@
|
||||
static const char help_message[] = "Print a usage message";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char input_message[] = "Optional. Path to a folder with images and/or binaries or to specific image or binary file.";
|
||||
static const char input_message[] =
|
||||
"Optional. Path to a folder with images and/or binaries or to specific image or binary file.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char model_message[] = "Required. Path to an .xml/.onnx/.prototxt file with a trained model or to a .blob files with "
|
||||
"a trained compiled model.";
|
||||
static const char model_message[] =
|
||||
"Required. Path to an .xml/.onnx/.prototxt file with a trained model or to a .blob files with "
|
||||
"a trained compiled model.";
|
||||
|
||||
/// @brief message for execution mode
|
||||
static const char api_message[] = "Optional. Enable Sync/Async API. Default value is \"async\".";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] = "Optional. Specify a target device to infer on (the list of available devices is shown below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma-separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Use \"-d MULTI:<comma-separated_devices_list>\" format to specify MULTI plugin. "
|
||||
"The application looks for a suitable plugin for the specified device.";
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify a target device to infer on (the list of available devices is shown below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma-separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Use \"-d MULTI:<comma-separated_devices_list>\" format to specify MULTI plugin. "
|
||||
"The application looks for a suitable plugin for the specified device.";
|
||||
|
||||
/// @brief message for iterations count
|
||||
static const char iterations_count_message[] = "Optional. Number of iterations. "
|
||||
"If not specified, the number of iterations is calculated depending on a device.";
|
||||
static const char iterations_count_message[] =
|
||||
"Optional. Number of iterations. "
|
||||
"If not specified, the number of iterations is calculated depending on a device.";
|
||||
|
||||
/// @brief message for requests count
|
||||
static const char infer_requests_count_message[] = "Optional. Number of infer requests. Default value is determined automatically for device.";
|
||||
static const char infer_requests_count_message[] =
|
||||
"Optional. Number of infer requests. Default value is determined automatically for device.";
|
||||
|
||||
/// @brief message for execution time
|
||||
static const char execution_time_message[] = "Optional. Time in seconds to execute topology.";
|
||||
@ -45,86 +50,101 @@ static const char infer_num_threads_message[] = "Optional. Number of threads to
|
||||
"(including HETERO and MULTI cases).";
|
||||
|
||||
/// @brief message for #streams for CPU inference
|
||||
static const char infer_num_streams_message[] = "Optional. Number of streams to use for inference on the CPU, GPU or MYRIAD devices "
|
||||
"(for HETERO and MULTI device cases use format <dev1>:<nstreams1>,<dev2>:<nstreams2> or just "
|
||||
"<nstreams>). "
|
||||
"Default value is determined automatically for a device.Please note that although the "
|
||||
"automatic selection "
|
||||
"usually provides a reasonable performance, it still may be non - optimal for some cases, "
|
||||
"especially for "
|
||||
"very small networks. See sample's README for more details. "
|
||||
"Also, using nstreams>1 is inherently throughput-oriented option, "
|
||||
"while for the best-latency estimations the number of streams should be set to 1.";
|
||||
static const char infer_num_streams_message[] =
|
||||
"Optional. Number of streams to use for inference on the CPU, GPU or MYRIAD devices "
|
||||
"(for HETERO and MULTI device cases use format <dev1>:<nstreams1>,<dev2>:<nstreams2> or just "
|
||||
"<nstreams>). "
|
||||
"Default value is determined automatically for a device.Please note that although the "
|
||||
"automatic selection "
|
||||
"usually provides a reasonable performance, it still may be non - optimal for some cases, "
|
||||
"especially for "
|
||||
"very small networks. See sample's README for more details. "
|
||||
"Also, using nstreams>1 is inherently throughput-oriented option, "
|
||||
"while for the best-latency estimations the number of streams should be set to 1.";
|
||||
|
||||
/// @brief message for latency percentile settings
|
||||
static const char infer_latency_percentile_message[] =
|
||||
"Optional. Defines the percentile to be reported in latency metric. The valid range is [1, 100]. The default value is 50 (median).";
|
||||
"Optional. Defines the percentile to be reported in latency metric. The valid range is [1, 100]. The default value "
|
||||
"is 50 (median).";
|
||||
|
||||
/// @brief message for enforcing of BF16 execution where it is possible
|
||||
static const char enforce_bf16_message[] = "Optional. By default floating point operations execution in bfloat16 precision are enforced "
|
||||
"if supported by platform.\n"
|
||||
" 'true' - enable bfloat16 regardless of platform support\n"
|
||||
" 'false' - disable bfloat16 regardless of platform support";
|
||||
static const char enforce_bf16_message[] =
|
||||
"Optional. By default floating point operations execution in bfloat16 precision are enforced "
|
||||
"if supported by platform.\n"
|
||||
" 'true' - enable bfloat16 regardless of platform support\n"
|
||||
" 'false' - disable bfloat16 regardless of platform support";
|
||||
|
||||
/// @brief message for user library argument
|
||||
static const char custom_cpu_library_message[] = "Required for CPU custom layers. Absolute path to a shared library with the kernels "
|
||||
"implementations.";
|
||||
static const char custom_cpu_library_message[] =
|
||||
"Required for CPU custom layers. Absolute path to a shared library with the kernels "
|
||||
"implementations.";
|
||||
|
||||
/// @brief message for clDNN custom kernels desc
|
||||
static const char custom_cldnn_message[] = "Required for GPU custom kernels. Absolute path to an .xml file with the kernels description.";
|
||||
static const char custom_cldnn_message[] =
|
||||
"Required for GPU custom kernels. Absolute path to an .xml file with the kernels description.";
|
||||
|
||||
static const char batch_size_message[] = "Optional. Batch size value. If not specified, the batch size value is determined from "
|
||||
"Intermediate Representation.";
|
||||
static const char batch_size_message[] =
|
||||
"Optional. Batch size value. If not specified, the batch size value is determined from "
|
||||
"Intermediate Representation.";
|
||||
|
||||
// @brief message for CPU threads pinning option
|
||||
static const char infer_threads_pinning_message[] =
|
||||
"Optional. Explicit inference threads binding options (leave empty to let the OpenVINO to make a choice):\n"
|
||||
"\t\t\t\tenabling threads->cores pinning(\"YES\", which is already default for any conventional CPU), \n"
|
||||
"\t\t\t\tletting the runtime to decide on the threads->different core types(\"HYBRID_AWARE\", which is default on the hybrid CPUs) \n"
|
||||
"\t\t\t\tletting the runtime to decide on the threads->different core types(\"HYBRID_AWARE\", which is default on "
|
||||
"the hybrid CPUs) \n"
|
||||
"\t\t\t\tthreads->(NUMA)nodes(\"NUMA\") or \n"
|
||||
"\t\t\t\tcompletely disable(\"NO\") CPU inference threads pinning";
|
||||
// @brief message for stream_output option
|
||||
static const char stream_output_message[] = "Optional. Print progress as a plain text. When specified, an interactive progress bar is "
|
||||
"replaced with a "
|
||||
"multiline output.";
|
||||
static const char stream_output_message[] =
|
||||
"Optional. Print progress as a plain text. When specified, an interactive progress bar is "
|
||||
"replaced with a "
|
||||
"multiline output.";
|
||||
|
||||
// @brief message for report_type option
|
||||
static const char report_type_message[] = "Optional. Enable collecting statistics report. \"no_counters\" report contains "
|
||||
"configuration options specified, resulting FPS and latency. \"average_counters\" "
|
||||
"report extends \"no_counters\" report and additionally includes average PM "
|
||||
"counters values for each layer from the network. \"detailed_counters\" report "
|
||||
"extends \"average_counters\" report and additionally includes per-layer PM "
|
||||
"counters and latency for each executed infer request.";
|
||||
static const char report_type_message[] =
|
||||
"Optional. Enable collecting statistics report. \"no_counters\" report contains "
|
||||
"configuration options specified, resulting FPS and latency. \"average_counters\" "
|
||||
"report extends \"no_counters\" report and additionally includes average PM "
|
||||
"counters values for each layer from the network. \"detailed_counters\" report "
|
||||
"extends \"average_counters\" report and additionally includes per-layer PM "
|
||||
"counters and latency for each executed infer request.";
|
||||
|
||||
// @brief message for report_folder option
|
||||
static const char report_folder_message[] = "Optional. Path to a folder where statistics report is stored.";
|
||||
|
||||
// @brief message for exec_graph_path option
|
||||
static const char exec_graph_path_message[] = "Optional. Path to a file where to store executable graph information serialized.";
|
||||
static const char exec_graph_path_message[] =
|
||||
"Optional. Path to a file where to store executable graph information serialized.";
|
||||
|
||||
// @brief message for progress bar option
|
||||
static const char progress_message[] = "Optional. Show progress bar (can affect performance measurement). Default values is "
|
||||
"\"false\".";
|
||||
static const char progress_message[] =
|
||||
"Optional. Show progress bar (can affect performance measurement). Default values is "
|
||||
"\"false\".";
|
||||
|
||||
// @brief message for performance counters option
|
||||
static const char pc_message[] = "Optional. Report performance counters.";
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
// @brief message for load config option
|
||||
static const char load_config_message[] = "Optional. Path to XML/YAML/JSON file to load custom IE parameters."
|
||||
" Please note, command line parameters have higher priority then parameters from configuration "
|
||||
"file.";
|
||||
static const char load_config_message[] =
|
||||
"Optional. Path to XML/YAML/JSON file to load custom IE parameters."
|
||||
" Please note, command line parameters have higher priority then parameters from configuration "
|
||||
"file.";
|
||||
|
||||
// @brief message for dump config option
|
||||
static const char dump_config_message[] = "Optional. Path to XML/YAML/JSON file to dump IE parameters, which were set by application.";
|
||||
static const char dump_config_message[] =
|
||||
"Optional. Path to XML/YAML/JSON file to dump IE parameters, which were set by application.";
|
||||
#endif
|
||||
|
||||
static const char shape_message[] = "Optional. Set shape for input. For example, \"input1[1,3,224,224],input2[1,4]\" or "
|
||||
"\"[1,3,224,224]\""
|
||||
" in case of one input size.";
|
||||
static const char shape_message[] =
|
||||
"Optional. Set shape for input. For example, \"input1[1,3,224,224],input2[1,4]\" or "
|
||||
"\"[1,3,224,224]\""
|
||||
" in case of one input size.";
|
||||
|
||||
static const char layout_message[] = "Optional. Prompts how network layouts should be treated by application. "
|
||||
"For example, \"input1[NCHW],input2[NC]\" or \"[NCHW]\" in case of one input size.";
|
||||
static const char layout_message[] =
|
||||
"Optional. Prompts how network layouts should be treated by application. "
|
||||
"For example, \"input1[NCHW],input2[NC]\" or \"[NCHW]\" in case of one input size.";
|
||||
|
||||
// @brief message for enabling caching
|
||||
static const char cache_dir_message[] = "Optional. Enables caching of loaded models to specified directory. "
|
||||
@ -139,21 +159,25 @@ static const char gna_qb_message[] = "Optional. Weight bits for quantization: 8
|
||||
|
||||
static constexpr char inputs_precision_message[] = "Optional. Specifies precision for all input layers of the network.";
|
||||
|
||||
static constexpr char outputs_precision_message[] = "Optional. Specifies precision for all output layers of the network.";
|
||||
static constexpr char outputs_precision_message[] =
|
||||
"Optional. Specifies precision for all output layers of the network.";
|
||||
|
||||
static constexpr char iop_message[] = "Optional. Specifies precision for input and output layers by name.\n"
|
||||
" Example: -iop \"input:FP16, output:FP16\".\n"
|
||||
" Notice that quotes are required.\n"
|
||||
" Overwrites precision from ip and op options for "
|
||||
"specified layers.";
|
||||
static constexpr char iop_message[] =
|
||||
"Optional. Specifies precision for input and output layers by name.\n"
|
||||
" Example: -iop \"input:FP16, output:FP16\".\n"
|
||||
" Notice that quotes are required.\n"
|
||||
" Overwrites precision from ip and op options for "
|
||||
"specified layers.";
|
||||
|
||||
static constexpr char input_image_scale_message[] = "Optional. Scale values to be used for the input image per channel.\n"
|
||||
"Values to be provided in the [R, G, B] format. Can be defined for desired input of the model.\n"
|
||||
"Example: -iscale data[255,255,255],info[255,255,255]\n";
|
||||
static constexpr char input_image_scale_message[] =
|
||||
"Optional. Scale values to be used for the input image per channel.\n"
|
||||
"Values to be provided in the [R, G, B] format. Can be defined for desired input of the model.\n"
|
||||
"Example: -iscale data[255,255,255],info[255,255,255]\n";
|
||||
|
||||
static constexpr char input_image_mean_message[] = "Optional. Mean values to be used for the input image per channel.\n"
|
||||
"Values to be provided in the [R, G, B] format. Can be defined for desired input of the model,\n"
|
||||
"Example: -imean data[255,255,255],info[255,255,255]\n";
|
||||
static constexpr char input_image_mean_message[] =
|
||||
"Optional. Mean values to be used for the input image per channel.\n"
|
||||
"Values to be provided in the [R, G, B] format. Can be defined for desired input of the model,\n"
|
||||
"Example: -imean data[255,255,255],info[255,255,255]\n";
|
||||
|
||||
/// @brief Define flag for showing help message <br>
|
||||
DEFINE_bool(h, false, help_message);
|
||||
|
@ -23,7 +23,8 @@ typedef std::chrono::nanoseconds ns;
|
||||
|
||||
typedef std::function<void(size_t id, const double latency)> QueueCallbackFunction;
|
||||
|
||||
/// @brief Wrapper class for InferenceEngine::InferRequest. Handles asynchronous callbacks and calculates execution time.
|
||||
/// @brief Wrapper class for InferenceEngine::InferRequest. Handles asynchronous callbacks and calculates execution
|
||||
/// time.
|
||||
class InferReqWrap final {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<InferReqWrap>;
|
||||
@ -31,7 +32,9 @@ public:
|
||||
~InferReqWrap() = default;
|
||||
|
||||
explicit InferReqWrap(InferenceEngine::ExecutableNetwork& net, size_t id, QueueCallbackFunction callbackQueue)
|
||||
: _request(net.CreateInferRequest()), _id(id), _callbackQueue(callbackQueue) {
|
||||
: _request(net.CreateInferRequest()),
|
||||
_id(id),
|
||||
_callbackQueue(callbackQueue) {
|
||||
_request.SetCompletionCallback([&]() {
|
||||
_endTime = Time::now();
|
||||
_callbackQueue(_id, getExecutionTimeInMilliseconds());
|
||||
@ -79,8 +82,10 @@ class InferRequestsQueue final {
|
||||
public:
|
||||
InferRequestsQueue(InferenceEngine::ExecutableNetwork& net, size_t nireq) {
|
||||
for (size_t id = 0; id < nireq; id++) {
|
||||
requests.push_back(
|
||||
std::make_shared<InferReqWrap>(net, id, std::bind(&InferRequestsQueue::putIdleRequest, this, std::placeholders::_1, std::placeholders::_2)));
|
||||
requests.push_back(std::make_shared<InferReqWrap>(
|
||||
net,
|
||||
id,
|
||||
std::bind(&InferRequestsQueue::putIdleRequest, this, std::placeholders::_1, std::placeholders::_2)));
|
||||
_idleIds.push(id);
|
||||
}
|
||||
resetTimes();
|
||||
@ -90,7 +95,8 @@ public:
|
||||
// So it should be released before any context that the request can use inside internal asynchronous tasks
|
||||
// For example all members of InferRequestsQueue would be destroyed before `requests` vector
|
||||
// So requests can try to use this members from `putIdleRequest()` that would be called from request callback
|
||||
// To avoid this we should move this vector declaration after all members declaration or just clear it manually in destructor
|
||||
// To avoid this we should move this vector declaration after all members declaration or just clear it manually
|
||||
// in destructor
|
||||
requests.clear();
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,15 @@
|
||||
using namespace InferenceEngine;
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
static const std::vector<std::string> supported_image_extensions = {"bmp", "dib", "jpeg", "jpg", "jpe", "jp2", "png",
|
||||
"pbm", "pgm", "ppm", "sr", "ras", "tiff", "tif"};
|
||||
static const std::vector<std::string> supported_image_extensions =
|
||||
{"bmp", "dib", "jpeg", "jpg", "jpe", "jp2", "png", "pbm", "pgm", "ppm", "sr", "ras", "tiff", "tif"};
|
||||
#else
|
||||
static const std::vector<std::string> supported_image_extensions = {"bmp"};
|
||||
#endif
|
||||
static const std::vector<std::string> supported_binary_extensions = {"bin"};
|
||||
|
||||
std::vector<std::string> filterFilesByExtensions(const std::vector<std::string>& filePaths, const std::vector<std::string>& extensions) {
|
||||
std::vector<std::string> filterFilesByExtensions(const std::vector<std::string>& filePaths,
|
||||
const std::vector<std::string>& extensions) {
|
||||
std::vector<std::string> filtered;
|
||||
auto getExtension = [](const std::string& name) {
|
||||
auto extensionPosition = name.rfind('.', name.size());
|
||||
@ -40,8 +41,13 @@ std::vector<std::string> filterFilesByExtensions(const std::vector<std::string>&
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fillBlobImage(Blob::Ptr& inputBlob, const std::vector<std::string>& filePaths, const size_t& batchSize, const benchmark_app::InputInfo& app_info,
|
||||
const size_t& requestId, const size_t& inputId, const size_t& inputSize) {
|
||||
void fillBlobImage(Blob::Ptr& inputBlob,
|
||||
const std::vector<std::string>& filePaths,
|
||||
const size_t& batchSize,
|
||||
const benchmark_app::InputInfo& app_info,
|
||||
const size_t& requestId,
|
||||
const size_t& inputId,
|
||||
const size_t& inputSize) {
|
||||
MemoryBlob::Ptr minput = as<MemoryBlob>(inputBlob);
|
||||
if (!minput) {
|
||||
IE_THROW() << "We expect inputBlob to be inherited from MemoryBlob in "
|
||||
@ -57,7 +63,8 @@ void fillBlobImage(Blob::Ptr& inputBlob, const std::vector<std::string>& filePat
|
||||
std::vector<std::shared_ptr<uint8_t>> vreader;
|
||||
vreader.reserve(batchSize);
|
||||
|
||||
for (size_t i = 0ULL, inputIndex = requestId * batchSize * inputSize + inputId; i < batchSize; i++, inputIndex += inputSize) {
|
||||
for (size_t i = 0ULL, inputIndex = requestId * batchSize * inputSize + inputId; i < batchSize;
|
||||
i++, inputIndex += inputSize) {
|
||||
inputIndex %= filePaths.size();
|
||||
|
||||
slog::info << "Prepare image " << filePaths[inputIndex] << slog::endl;
|
||||
@ -88,11 +95,13 @@ void fillBlobImage(Blob::Ptr& inputBlob, const std::vector<std::string>& filePat
|
||||
for (size_t ch = 0; ch < numChannels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in
|
||||
* bytes **/
|
||||
size_t offset = imageId * numChannels * width * height + (((app_info.layout == "NCHW") || (app_info.layout == "CHW"))
|
||||
? (ch * width * height + h * width + w)
|
||||
: (h * width * numChannels + w * numChannels + ch));
|
||||
size_t offset = imageId * numChannels * width * height +
|
||||
(((app_info.layout == "NCHW") || (app_info.layout == "CHW"))
|
||||
? (ch * width * height + h * width + w)
|
||||
: (h * width * numChannels + w * numChannels + ch));
|
||||
inputBlobData[offset] =
|
||||
(static_cast<T>(vreader.at(imageId).get()[h * width * numChannels + w * numChannels + ch]) - static_cast<T>(app_info.mean[ch])) /
|
||||
(static_cast<T>(vreader.at(imageId).get()[h * width * numChannels + w * numChannels + ch]) -
|
||||
static_cast<T>(app_info.mean[ch])) /
|
||||
static_cast<T>(app_info.scale[ch]);
|
||||
}
|
||||
}
|
||||
@ -101,7 +110,11 @@ void fillBlobImage(Blob::Ptr& inputBlob, const std::vector<std::string>& filePat
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fillBlobBinary(Blob::Ptr& inputBlob, const std::vector<std::string>& filePaths, const size_t& batchSize, const size_t& requestId, const size_t& inputId,
|
||||
void fillBlobBinary(Blob::Ptr& inputBlob,
|
||||
const std::vector<std::string>& filePaths,
|
||||
const size_t& batchSize,
|
||||
const size_t& requestId,
|
||||
const size_t& inputId,
|
||||
const size_t& inputSize) {
|
||||
MemoryBlob::Ptr minput = as<MemoryBlob>(inputBlob);
|
||||
if (!minput) {
|
||||
@ -114,7 +127,8 @@ void fillBlobBinary(Blob::Ptr& inputBlob, const std::vector<std::string>& filePa
|
||||
auto minputHolder = minput->wmap();
|
||||
|
||||
auto inputBlobData = minputHolder.as<char*>();
|
||||
for (size_t i = 0ULL, inputIndex = requestId * batchSize * inputSize + inputId; i < batchSize; i++, inputIndex += inputSize) {
|
||||
for (size_t i = 0ULL, inputIndex = requestId * batchSize * inputSize + inputId; i < batchSize;
|
||||
i++, inputIndex += inputSize) {
|
||||
inputIndex %= filePaths.size();
|
||||
|
||||
slog::info << "Prepare binary file " << filePaths[inputIndex] << slog::endl;
|
||||
@ -140,12 +154,15 @@ void fillBlobBinary(Blob::Ptr& inputBlob, const std::vector<std::string>& filePa
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
using uniformDistribution =
|
||||
typename std::conditional<std::is_floating_point<T>::value, std::uniform_real_distribution<T>,
|
||||
typename std::conditional<std::is_integral<T>::value, std::uniform_int_distribution<T>, void>::type>::type;
|
||||
using uniformDistribution = typename std::conditional<
|
||||
std::is_floating_point<T>::value,
|
||||
std::uniform_real_distribution<T>,
|
||||
typename std::conditional<std::is_integral<T>::value, std::uniform_int_distribution<T>, void>::type>::type;
|
||||
|
||||
template <typename T, typename T2>
|
||||
void fillBlobRandom(Blob::Ptr& inputBlob, T rand_min = std::numeric_limits<uint8_t>::min(), T rand_max = std::numeric_limits<uint8_t>::max()) {
|
||||
void fillBlobRandom(Blob::Ptr& inputBlob,
|
||||
T rand_min = std::numeric_limits<uint8_t>::min(),
|
||||
T rand_max = std::numeric_limits<uint8_t>::max()) {
|
||||
MemoryBlob::Ptr minput = as<MemoryBlob>(inputBlob);
|
||||
if (!minput) {
|
||||
IE_THROW() << "We expect inputBlob to be inherited from MemoryBlob in "
|
||||
@ -191,14 +208,17 @@ void fillBlobImInfo(Blob::Ptr& inputBlob, const size_t& batchSize, std::pair<siz
|
||||
}
|
||||
}
|
||||
|
||||
void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSize, benchmark_app::InputsInfo& app_inputs_info,
|
||||
void fillBlobs(const std::vector<std::string>& inputFiles,
|
||||
const size_t& batchSize,
|
||||
benchmark_app::InputsInfo& app_inputs_info,
|
||||
std::vector<InferReqWrap::Ptr> requests) {
|
||||
std::vector<std::pair<size_t, size_t>> input_image_sizes;
|
||||
for (auto& item : app_inputs_info) {
|
||||
if (item.second.isImage()) {
|
||||
input_image_sizes.push_back(std::make_pair(item.second.width(), item.second.height()));
|
||||
}
|
||||
slog::info << "Network input '" << item.first << "' precision " << item.second.precision << ", dimensions (" << item.second.layout << "): ";
|
||||
slog::info << "Network input '" << item.first << "' precision " << item.second.precision << ", dimensions ("
|
||||
<< item.second.layout << "): ";
|
||||
for (const auto& i : item.second.shape) {
|
||||
slog::info << i << " ";
|
||||
}
|
||||
@ -232,10 +252,11 @@ void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSi
|
||||
"extensions: "
|
||||
<< ss.str() << slog::endl;
|
||||
} else if (binaryToBeUsed > binaryFiles.size()) {
|
||||
slog::warn << "Some binary input files will be duplicated: " << binaryToBeUsed << " files are required but only " << binaryFiles.size()
|
||||
<< " are provided" << slog::endl;
|
||||
slog::warn << "Some binary input files will be duplicated: " << binaryToBeUsed
|
||||
<< " files are required but only " << binaryFiles.size() << " are provided" << slog::endl;
|
||||
} else if (binaryToBeUsed < binaryFiles.size()) {
|
||||
slog::warn << "Some binary input files will be ignored: only " << binaryToBeUsed << " are required from " << binaryFiles.size() << slog::endl;
|
||||
slog::warn << "Some binary input files will be ignored: only " << binaryToBeUsed << " are required from "
|
||||
<< binaryFiles.size() << slog::endl;
|
||||
}
|
||||
|
||||
imageFiles = filterFilesByExtensions(inputFiles, supported_image_extensions);
|
||||
@ -254,10 +275,11 @@ void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSi
|
||||
"extensions: "
|
||||
<< ss.str() << slog::endl;
|
||||
} else if (imagesToBeUsed > imageFiles.size()) {
|
||||
slog::warn << "Some image input files will be duplicated: " << imagesToBeUsed << " files are required but only " << imageFiles.size()
|
||||
<< " are provided" << slog::endl;
|
||||
slog::warn << "Some image input files will be duplicated: " << imagesToBeUsed
|
||||
<< " files are required but only " << imageFiles.size() << " are provided" << slog::endl;
|
||||
} else if (imagesToBeUsed < imageFiles.size()) {
|
||||
slog::warn << "Some image input files will be ignored: only " << imagesToBeUsed << " are required from " << imageFiles.size() << slog::endl;
|
||||
slog::warn << "Some image input files will be ignored: only " << imagesToBeUsed << " are required from "
|
||||
<< imageFiles.size() << slog::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,15 +296,45 @@ void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSi
|
||||
if (!imageFiles.empty()) {
|
||||
// Fill with Images
|
||||
if (precision == InferenceEngine::Precision::FP32) {
|
||||
fillBlobImage<float>(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount);
|
||||
fillBlobImage<float>(inputBlob,
|
||||
imageFiles,
|
||||
batchSize,
|
||||
app_info,
|
||||
requestId,
|
||||
imageInputId++,
|
||||
imageInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::FP16) {
|
||||
fillBlobImage<short>(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount);
|
||||
fillBlobImage<short>(inputBlob,
|
||||
imageFiles,
|
||||
batchSize,
|
||||
app_info,
|
||||
requestId,
|
||||
imageInputId++,
|
||||
imageInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::I32) {
|
||||
fillBlobImage<int32_t>(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount);
|
||||
fillBlobImage<int32_t>(inputBlob,
|
||||
imageFiles,
|
||||
batchSize,
|
||||
app_info,
|
||||
requestId,
|
||||
imageInputId++,
|
||||
imageInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::I64) {
|
||||
fillBlobImage<int64_t>(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount);
|
||||
fillBlobImage<int64_t>(inputBlob,
|
||||
imageFiles,
|
||||
batchSize,
|
||||
app_info,
|
||||
requestId,
|
||||
imageInputId++,
|
||||
imageInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::U8) {
|
||||
fillBlobImage<uint8_t>(inputBlob, imageFiles, batchSize, app_info, requestId, imageInputId++, imageInputCount);
|
||||
fillBlobImage<uint8_t>(inputBlob,
|
||||
imageFiles,
|
||||
batchSize,
|
||||
app_info,
|
||||
requestId,
|
||||
imageInputId++,
|
||||
imageInputCount);
|
||||
} else {
|
||||
IE_THROW() << "Input precision is not supported for " << item.first;
|
||||
}
|
||||
@ -292,15 +344,41 @@ void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSi
|
||||
if (!binaryFiles.empty()) {
|
||||
// Fill with binary files
|
||||
if (precision == InferenceEngine::Precision::FP32) {
|
||||
fillBlobBinary<float>(inputBlob, binaryFiles, batchSize, requestId, binaryInputId++, binaryInputCount);
|
||||
fillBlobBinary<float>(inputBlob,
|
||||
binaryFiles,
|
||||
batchSize,
|
||||
requestId,
|
||||
binaryInputId++,
|
||||
binaryInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::FP16) {
|
||||
fillBlobBinary<short>(inputBlob, binaryFiles, batchSize, requestId, binaryInputId++, binaryInputCount);
|
||||
fillBlobBinary<short>(inputBlob,
|
||||
binaryFiles,
|
||||
batchSize,
|
||||
requestId,
|
||||
binaryInputId++,
|
||||
binaryInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::I32) {
|
||||
fillBlobBinary<int32_t>(inputBlob, binaryFiles, batchSize, requestId, binaryInputId++, binaryInputCount);
|
||||
fillBlobBinary<int32_t>(inputBlob,
|
||||
binaryFiles,
|
||||
batchSize,
|
||||
requestId,
|
||||
binaryInputId++,
|
||||
binaryInputCount);
|
||||
} else if (precision == InferenceEngine::Precision::I64) {
|
||||
fillBlobBinary<int64_t>(inputBlob, binaryFiles, batchSize, requestId, binaryInputId++, binaryInputCount);
|
||||
} else if ((precision == InferenceEngine::Precision::U8) || (precision == InferenceEngine::Precision::BOOL)) {
|
||||
fillBlobBinary<uint8_t>(inputBlob, binaryFiles, batchSize, requestId, binaryInputId++, binaryInputCount);
|
||||
fillBlobBinary<int64_t>(inputBlob,
|
||||
binaryFiles,
|
||||
batchSize,
|
||||
requestId,
|
||||
binaryInputId++,
|
||||
binaryInputCount);
|
||||
} else if ((precision == InferenceEngine::Precision::U8) ||
|
||||
(precision == InferenceEngine::Precision::BOOL)) {
|
||||
fillBlobBinary<uint8_t>(inputBlob,
|
||||
binaryFiles,
|
||||
batchSize,
|
||||
requestId,
|
||||
binaryInputId++,
|
||||
binaryInputCount);
|
||||
} else {
|
||||
IE_THROW() << "Input precision is not supported for " << item.first;
|
||||
}
|
||||
@ -310,7 +388,8 @@ void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSi
|
||||
if (app_info.isImageInfo() && (input_image_sizes.size() == 1)) {
|
||||
// Most likely it is image info: fill with image information
|
||||
auto image_size = input_image_sizes.at(0);
|
||||
slog::info << "Fill input '" << item.first << "' with image size " << image_size.first << "x" << image_size.second << slog::endl;
|
||||
slog::info << "Fill input '" << item.first << "' with image size " << image_size.first << "x"
|
||||
<< image_size.second << slog::endl;
|
||||
if (precision == InferenceEngine::Precision::FP32) {
|
||||
fillBlobImInfo<float>(inputBlob, batchSize, image_size);
|
||||
} else if (precision == InferenceEngine::Precision::FP16) {
|
||||
@ -326,8 +405,9 @@ void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSi
|
||||
}
|
||||
}
|
||||
// Fill random
|
||||
slog::info << "Fill input '" << item.first << "' with random values (" << std::string((app_info.isImage() ? "image" : "some binary data"))
|
||||
<< " is expected)" << slog::endl;
|
||||
slog::info << "Fill input '" << item.first << "' with random values ("
|
||||
<< std::string((app_info.isImage() ? "image" : "some binary data")) << " is expected)"
|
||||
<< slog::endl;
|
||||
if (precision == InferenceEngine::Precision::FP32) {
|
||||
fillBlobRandom<float, float>(inputBlob);
|
||||
} else if (precision == InferenceEngine::Precision::FP16) {
|
||||
|
@ -11,5 +11,7 @@
|
||||
#include "infer_request_wrap.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
void fillBlobs(const std::vector<std::string>& inputFiles, const size_t& batchSize, benchmark_app::InputsInfo& app_inputs_info,
|
||||
void fillBlobs(const std::vector<std::string>& inputFiles,
|
||||
const size_t& batchSize,
|
||||
benchmark_app::InputsInfo& app_inputs_info,
|
||||
std::vector<InferReqWrap::Ptr> requests);
|
@ -60,8 +60,10 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
throw std::logic_error("Incorrect API. Please set -api option to `sync` or `async` value.");
|
||||
}
|
||||
|
||||
if (!FLAGS_report_type.empty() && FLAGS_report_type != noCntReport && FLAGS_report_type != averageCntReport && FLAGS_report_type != detailedCntReport) {
|
||||
std::string err = "only " + std::string(noCntReport) + "/" + std::string(averageCntReport) + "/" + std::string(detailedCntReport) +
|
||||
if (!FLAGS_report_type.empty() && FLAGS_report_type != noCntReport && FLAGS_report_type != averageCntReport &&
|
||||
FLAGS_report_type != detailedCntReport) {
|
||||
std::string err = "only " + std::string(noCntReport) + "/" + std::string(averageCntReport) + "/" +
|
||||
std::string(detailedCntReport) +
|
||||
" report types are supported (invalid -report_type option value)";
|
||||
throw std::logic_error(err);
|
||||
}
|
||||
@ -73,8 +75,9 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
bool isNetworkCompiled = fileExt(FLAGS_m) == "blob";
|
||||
bool isPrecisionSet = !(FLAGS_ip.empty() && FLAGS_op.empty() && FLAGS_iop.empty());
|
||||
if (isNetworkCompiled && isPrecisionSet) {
|
||||
std::string err = std::string("Cannot set precision for a compiled network. ") + std::string("Please re-compile your network with required precision "
|
||||
"using compile_tool");
|
||||
std::string err = std::string("Cannot set precision for a compiled network. ") +
|
||||
std::string("Please re-compile your network with required precision "
|
||||
"using compile_tool");
|
||||
|
||||
throw std::logic_error(err);
|
||||
}
|
||||
@ -83,17 +86,18 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
|
||||
static void next_step(const std::string additional_info = "") {
|
||||
static size_t step_id = 0;
|
||||
static const std::map<size_t, std::string> step_names = {{1, "Parsing and validating input arguments"},
|
||||
{2, "Loading Inference Engine"},
|
||||
{3, "Setting device configuration"},
|
||||
{4, "Reading network files"},
|
||||
{5, "Resizing network to match image sizes and given batch"},
|
||||
{6, "Configuring input of the model"},
|
||||
{7, "Loading the model to the device"},
|
||||
{8, "Setting optimal runtime parameters"},
|
||||
{9, "Creating infer requests and filling input blobs with images"},
|
||||
{10, "Measuring performance"},
|
||||
{11, "Dumping statistics report"}};
|
||||
static const std::map<size_t, std::string> step_names = {
|
||||
{1, "Parsing and validating input arguments"},
|
||||
{2, "Loading Inference Engine"},
|
||||
{3, "Setting device configuration"},
|
||||
{4, "Reading network files"},
|
||||
{5, "Resizing network to match image sizes and given batch"},
|
||||
{6, "Configuring input of the model"},
|
||||
{7, "Loading the model to the device"},
|
||||
{8, "Setting optimal runtime parameters"},
|
||||
{9, "Creating infer requests and filling input blobs with images"},
|
||||
{10, "Measuring performance"},
|
||||
{11, "Dumping statistics report"}};
|
||||
|
||||
step_id++;
|
||||
if (step_names.count(step_id) == 0)
|
||||
@ -140,13 +144,16 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
if (!FLAGS_report_type.empty()) {
|
||||
statistics = std::make_shared<StatisticsReport>(StatisticsReport::Config {FLAGS_report_type, FLAGS_report_folder});
|
||||
statistics =
|
||||
std::make_shared<StatisticsReport>(StatisticsReport::Config{FLAGS_report_type, FLAGS_report_folder});
|
||||
statistics->addParameters(StatisticsReport::Category::COMMAND_LINE_PARAMETERS, command_line_arguments);
|
||||
}
|
||||
auto isFlagSetInCommandLine = [&command_line_arguments](const std::string& name) {
|
||||
return (std::find_if(command_line_arguments.begin(), command_line_arguments.end(), [name](const std::pair<std::string, std::string>& p) {
|
||||
return p.first == name;
|
||||
}) != command_line_arguments.end());
|
||||
return (std::find_if(command_line_arguments.begin(),
|
||||
command_line_arguments.end(),
|
||||
[name](const std::pair<std::string, std::string>& p) {
|
||||
return p.first == name;
|
||||
}) != command_line_arguments.end());
|
||||
};
|
||||
|
||||
std::string device_name = FLAGS_d;
|
||||
@ -213,13 +220,17 @@ int main(int argc, char* argv[]) {
|
||||
if (isFlagSetInCommandLine("pc")) {
|
||||
// set to user defined value
|
||||
device_config[CONFIG_KEY(PERF_COUNT)] = FLAGS_pc ? CONFIG_VALUE(YES) : CONFIG_VALUE(NO);
|
||||
} else if (device_config.count(CONFIG_KEY(PERF_COUNT)) && (device_config.at(CONFIG_KEY(PERF_COUNT)) == "YES")) {
|
||||
slog::warn << "Performance counters for " << device << " device is turned on. To print results use -pc option." << slog::endl;
|
||||
} else if (device_config.count(CONFIG_KEY(PERF_COUNT)) &&
|
||||
(device_config.at(CONFIG_KEY(PERF_COUNT)) == "YES")) {
|
||||
slog::warn << "Performance counters for " << device
|
||||
<< " device is turned on. To print results use -pc option." << slog::endl;
|
||||
} else if (FLAGS_report_type == detailedCntReport || FLAGS_report_type == averageCntReport) {
|
||||
slog::warn << "Turn on performance counters for " << device << " device since report type is " << FLAGS_report_type << "." << slog::endl;
|
||||
slog::warn << "Turn on performance counters for " << device << " device since report type is "
|
||||
<< FLAGS_report_type << "." << slog::endl;
|
||||
device_config[CONFIG_KEY(PERF_COUNT)] = CONFIG_VALUE(YES);
|
||||
} else if (!FLAGS_exec_graph_path.empty()) {
|
||||
slog::warn << "Turn on performance counters for " << device << " device due to execution graph dumping." << slog::endl;
|
||||
slog::warn << "Turn on performance counters for " << device << " device due to execution graph dumping."
|
||||
<< slog::endl;
|
||||
device_config[CONFIG_KEY(PERF_COUNT)] = CONFIG_VALUE(YES);
|
||||
} else {
|
||||
// set to default value
|
||||
@ -231,8 +242,10 @@ int main(int argc, char* argv[]) {
|
||||
const std::string key = device + "_THROUGHPUT_STREAMS";
|
||||
if (device_nstreams.count(device)) {
|
||||
// set to user defined value
|
||||
std::vector<std::string> supported_config_keys = ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
|
||||
if (std::find(supported_config_keys.begin(), supported_config_keys.end(), key) == supported_config_keys.end()) {
|
||||
std::vector<std::string> supported_config_keys =
|
||||
ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
|
||||
if (std::find(supported_config_keys.begin(), supported_config_keys.end(), key) ==
|
||||
supported_config_keys.end()) {
|
||||
throw std::logic_error("Device " + device + " doesn't support config key '" + key + "'! " +
|
||||
"Please specify -nstreams for correct devices in format "
|
||||
"<dev1>:<nstreams1>,<dev2>:<nstreams2>" +
|
||||
@ -267,8 +280,10 @@ int main(int argc, char* argv[]) {
|
||||
// set to user defined value
|
||||
device_config[CONFIG_KEY(CPU_BIND_THREAD)] = FLAGS_pin;
|
||||
} else if (!device_config.count(CONFIG_KEY(CPU_BIND_THREAD))) {
|
||||
if ((device_name.find("MULTI") != std::string::npos) && (device_name.find("GPU") != std::string::npos)) {
|
||||
slog::warn << "Turn off threads pinning for " << device << " device since multi-scenario with GPU device is used." << slog::endl;
|
||||
if ((device_name.find("MULTI") != std::string::npos) &&
|
||||
(device_name.find("GPU") != std::string::npos)) {
|
||||
slog::warn << "Turn off threads pinning for " << device
|
||||
<< " device since multi-scenario with GPU device is used." << slog::endl;
|
||||
device_config[CONFIG_KEY(CPU_BIND_THREAD)] = CONFIG_VALUE(NO);
|
||||
}
|
||||
}
|
||||
@ -279,7 +294,8 @@ int main(int argc, char* argv[]) {
|
||||
// for GPU execution, more throughput-oriented execution via streams
|
||||
setThroughputStreams();
|
||||
|
||||
if ((device_name.find("MULTI") != std::string::npos) && (device_name.find("CPU") != std::string::npos)) {
|
||||
if ((device_name.find("MULTI") != std::string::npos) &&
|
||||
(device_name.find("CPU") != std::string::npos)) {
|
||||
slog::warn << "Turn on GPU throttling. Multi-device execution with "
|
||||
"the CPU + GPU performs best with GPU throttling hint, "
|
||||
<< "which releases another CPU thread (that is otherwise "
|
||||
@ -299,9 +315,11 @@ int main(int argc, char* argv[]) {
|
||||
if (isFlagSetInCommandLine("nthreads"))
|
||||
device_config[GNA_CONFIG_KEY(LIB_N_THREADS)] = std::to_string(FLAGS_nthreads);
|
||||
} else {
|
||||
std::vector<std::string> supported_config_keys = ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
|
||||
std::vector<std::string> supported_config_keys =
|
||||
ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
|
||||
auto supported = [&](const std::string& key) {
|
||||
return std::find(std::begin(supported_config_keys), std::end(supported_config_keys), key) != std::end(supported_config_keys);
|
||||
return std::find(std::begin(supported_config_keys), std::end(supported_config_keys), key) !=
|
||||
std::end(supported_config_keys);
|
||||
};
|
||||
if (supported(CONFIG_KEY(CPU_THREADS_NUM)) && isFlagSetInCommandLine("nthreads")) {
|
||||
device_config[CONFIG_KEY(CPU_THREADS_NUM)] = std::to_string(FLAGS_nthreads);
|
||||
@ -351,7 +369,8 @@ int main(int argc, char* argv[]) {
|
||||
auto duration_ms = double_to_string(get_total_ms_time(startTime));
|
||||
slog::info << "Load network took " << duration_ms << " ms" << slog::endl;
|
||||
if (statistics)
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"load network time (ms)", duration_ms}});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"load network time (ms)", duration_ms}});
|
||||
if (batchSize == 0) {
|
||||
batchSize = 1;
|
||||
}
|
||||
@ -367,7 +386,8 @@ int main(int argc, char* argv[]) {
|
||||
auto duration_ms = double_to_string(get_total_ms_time(startTime));
|
||||
slog::info << "Read network took " << duration_ms << " ms" << slog::endl;
|
||||
if (statistics)
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"read network time (ms)", duration_ms}});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"read network time (ms)", duration_ms}});
|
||||
|
||||
const InputsDataMap inputInfo(cnnNetwork.getInputsInfo());
|
||||
if (inputInfo.empty()) {
|
||||
@ -380,7 +400,13 @@ int main(int argc, char* argv[]) {
|
||||
batchSize = cnnNetwork.getBatchSize();
|
||||
// Parse input shapes if specified
|
||||
bool reshape = false;
|
||||
app_inputs_info = getInputsInfo<InputInfo::Ptr>(FLAGS_shape, FLAGS_layout, FLAGS_b, FLAGS_iscale, FLAGS_imean, inputInfo, reshape);
|
||||
app_inputs_info = getInputsInfo<InputInfo::Ptr>(FLAGS_shape,
|
||||
FLAGS_layout,
|
||||
FLAGS_b,
|
||||
FLAGS_iscale,
|
||||
FLAGS_imean,
|
||||
inputInfo,
|
||||
reshape);
|
||||
if (reshape) {
|
||||
InferenceEngine::ICNNNetwork::InputShapes shapes = {};
|
||||
for (auto& item : app_inputs_info)
|
||||
@ -391,13 +417,15 @@ int main(int argc, char* argv[]) {
|
||||
duration_ms = double_to_string(get_total_ms_time(startTime));
|
||||
slog::info << "Reshape network took " << duration_ms << " ms" << slog::endl;
|
||||
if (statistics)
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"reshape network time (ms)", duration_ms}});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"reshape network time (ms)", duration_ms}});
|
||||
}
|
||||
// use batch size according to provided layout and shapes
|
||||
batchSize = (!FLAGS_layout.empty()) ? getBatchSize(app_inputs_info) : cnnNetwork.getBatchSize();
|
||||
|
||||
topology_name = cnnNetwork.getName();
|
||||
slog::info << (FLAGS_b != 0 ? "Network batch size was changed to: " : "Network batch size: ") << batchSize << slog::endl;
|
||||
slog::info << (FLAGS_b != 0 ? "Network batch size was changed to: " : "Network batch size: ") << batchSize
|
||||
<< slog::endl;
|
||||
|
||||
// ----------------- 6. Configuring inputs and outputs
|
||||
// ----------------------------------------------------------------------
|
||||
@ -424,7 +452,8 @@ int main(int argc, char* argv[]) {
|
||||
duration_ms = double_to_string(get_total_ms_time(startTime));
|
||||
slog::info << "Load network took " << duration_ms << " ms" << slog::endl;
|
||||
if (statistics)
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"load network time (ms)", duration_ms}});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"load network time (ms)", duration_ms}});
|
||||
} else {
|
||||
next_step();
|
||||
slog::info << "Skipping the step for compiled network" << slog::endl;
|
||||
@ -440,8 +469,14 @@ int main(int argc, char* argv[]) {
|
||||
auto duration_ms = double_to_string(get_total_ms_time(startTime));
|
||||
slog::info << "Import network took " << duration_ms << " ms" << slog::endl;
|
||||
if (statistics)
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"import network time (ms)", duration_ms}});
|
||||
app_inputs_info = getInputsInfo<InputInfo::CPtr>(FLAGS_shape, FLAGS_layout, FLAGS_b, FLAGS_iscale, FLAGS_imean, exeNetwork.GetInputsInfo());
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"import network time (ms)", duration_ms}});
|
||||
app_inputs_info = getInputsInfo<InputInfo::CPtr>(FLAGS_shape,
|
||||
FLAGS_layout,
|
||||
FLAGS_b,
|
||||
FLAGS_iscale,
|
||||
FLAGS_imean,
|
||||
exeNetwork.GetInputsInfo());
|
||||
if (batchSize == 0) {
|
||||
batchSize = 1;
|
||||
}
|
||||
@ -479,8 +514,8 @@ int main(int argc, char* argv[]) {
|
||||
if ((niter > 0) && (FLAGS_api == "async")) {
|
||||
niter = ((niter + nireq - 1) / nireq) * nireq;
|
||||
if (FLAGS_niter != niter) {
|
||||
slog::warn << "Number of iterations was aligned by request number from " << FLAGS_niter << " to " << niter << " using number of requests "
|
||||
<< nireq << slog::endl;
|
||||
slog::warn << "Number of iterations was aligned by request number from " << FLAGS_niter << " to "
|
||||
<< niter << " using number of requests " << nireq << slog::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,23 +531,25 @@ int main(int argc, char* argv[]) {
|
||||
uint64_t duration_nanoseconds = getDurationInNanoseconds(duration_seconds);
|
||||
|
||||
if (statistics) {
|
||||
statistics->addParameters(StatisticsReport::Category::RUNTIME_CONFIG,
|
||||
{
|
||||
{"topology", topology_name},
|
||||
{"target device", device_name},
|
||||
{"API", FLAGS_api},
|
||||
{"precision", std::string(precision.name())},
|
||||
{"batch size", std::to_string(batchSize)},
|
||||
{"number of iterations", std::to_string(niter)},
|
||||
{"number of parallel infer requests", std::to_string(nireq)},
|
||||
{"duration (ms)", std::to_string(getDurationInMilliseconds(duration_seconds))},
|
||||
});
|
||||
statistics->addParameters(
|
||||
StatisticsReport::Category::RUNTIME_CONFIG,
|
||||
{
|
||||
{"topology", topology_name},
|
||||
{"target device", device_name},
|
||||
{"API", FLAGS_api},
|
||||
{"precision", std::string(precision.name())},
|
||||
{"batch size", std::to_string(batchSize)},
|
||||
{"number of iterations", std::to_string(niter)},
|
||||
{"number of parallel infer requests", std::to_string(nireq)},
|
||||
{"duration (ms)", std::to_string(getDurationInMilliseconds(duration_seconds))},
|
||||
});
|
||||
for (auto& nstreams : device_nstreams) {
|
||||
std::stringstream ss;
|
||||
ss << "number of " << nstreams.first << " streams";
|
||||
statistics->addParameters(StatisticsReport::Category::RUNTIME_CONFIG, {
|
||||
{ss.str(), nstreams.second},
|
||||
});
|
||||
statistics->addParameters(StatisticsReport::Category::RUNTIME_CONFIG,
|
||||
{
|
||||
{ss.str(), nstreams.second},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,7 +613,8 @@ int main(int argc, char* argv[]) {
|
||||
auto duration_ms = double_to_string(inferRequestsQueue.getLatencies()[0]);
|
||||
slog::info << "First inference took " << duration_ms << " ms" << slog::endl;
|
||||
if (statistics)
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"first inference time (ms)", duration_ms}});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"first inference time (ms)", duration_ms}});
|
||||
inferRequestsQueue.resetTimes();
|
||||
|
||||
auto startTime = Time::now();
|
||||
@ -587,7 +625,8 @@ int main(int argc, char* argv[]) {
|
||||
* executed in the same conditions **/
|
||||
ProgressBar progressBar(progressBarTotalCount, FLAGS_stream_output, FLAGS_progress);
|
||||
|
||||
while ((niter != 0LL && iteration < niter) || (duration_nanoseconds != 0LL && (uint64_t)execTime < duration_nanoseconds) ||
|
||||
while ((niter != 0LL && iteration < niter) ||
|
||||
(duration_nanoseconds != 0LL && (uint64_t)execTime < duration_nanoseconds) ||
|
||||
(FLAGS_api == "async" && iteration % nireq != 0)) {
|
||||
inferRequest = inferRequestsQueue.getIdleRequest();
|
||||
if (!inferRequest) {
|
||||
@ -629,13 +668,15 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
double latency = getMedianValue<double>(inferRequestsQueue.getLatencies(), FLAGS_latency_percentile);
|
||||
double totalDuration = inferRequestsQueue.getDurationInMilliseconds();
|
||||
double fps = (FLAGS_api == "sync") ? batchSize * 1000.0 / latency : batchSize * 1000.0 * iteration / totalDuration;
|
||||
double fps =
|
||||
(FLAGS_api == "sync") ? batchSize * 1000.0 / latency : batchSize * 1000.0 * iteration / totalDuration;
|
||||
|
||||
if (statistics) {
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {
|
||||
{"total execution time (ms)", double_to_string(totalDuration)},
|
||||
{"total number of iterations", std::to_string(iteration)},
|
||||
});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{
|
||||
{"total execution time (ms)", double_to_string(totalDuration)},
|
||||
{"total number of iterations", std::to_string(iteration)},
|
||||
});
|
||||
if (device_name.find("MULTI") == std::string::npos) {
|
||||
std::string latency_label;
|
||||
if (FLAGS_latency_percentile == 50) {
|
||||
@ -643,11 +684,13 @@ int main(int argc, char* argv[]) {
|
||||
} else {
|
||||
latency_label = "latency (" + std::to_string(FLAGS_latency_percentile) + " percentile) (ms)";
|
||||
}
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {
|
||||
{latency_label, double_to_string(latency)},
|
||||
});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{
|
||||
{latency_label, double_to_string(latency)},
|
||||
});
|
||||
}
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {{"throughput", double_to_string(fps)}});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"throughput", double_to_string(fps)}});
|
||||
}
|
||||
|
||||
progressBar.finish();
|
||||
@ -707,9 +750,10 @@ int main(int argc, char* argv[]) {
|
||||
slog::err << ex.what() << slog::endl;
|
||||
|
||||
if (statistics) {
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS, {
|
||||
{"error", ex.what()},
|
||||
});
|
||||
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{
|
||||
{"error", ex.what()},
|
||||
});
|
||||
statistics->dump();
|
||||
}
|
||||
|
||||
|
@ -35,14 +35,14 @@ public:
|
||||
EXECUTION_RESULTS,
|
||||
};
|
||||
|
||||
explicit StatisticsReport(Config config): _config(std::move(config)) {
|
||||
explicit StatisticsReport(Config config) : _config(std::move(config)) {
|
||||
_separator =
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#if defined UNICODE
|
||||
# if defined UNICODE
|
||||
L"\\";
|
||||
#else
|
||||
# else
|
||||
"\\";
|
||||
#endif
|
||||
# endif
|
||||
#else
|
||||
"/";
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
// clang-format on
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
#include <opencv2/core.hpp>
|
||||
# include <opencv2/core.hpp>
|
||||
#endif
|
||||
|
||||
namespace benchmark_app {
|
||||
@ -54,8 +54,13 @@ size_t InputInfo::depth() const {
|
||||
} // namespace benchmark_app
|
||||
|
||||
uint32_t deviceDefaultDeviceDurationInSeconds(const std::string& device) {
|
||||
static const std::map<std::string, uint32_t> deviceDefaultDurationInSeconds {{"CPU", 60}, {"GPU", 60}, {"VPU", 60}, {"MYRIAD", 60},
|
||||
{"HDDL", 60}, {"FPGA", 120}, {"UNKNOWN", 120}};
|
||||
static const std::map<std::string, uint32_t> deviceDefaultDurationInSeconds{{"CPU", 60},
|
||||
{"GPU", 60},
|
||||
{"VPU", 60},
|
||||
{"MYRIAD", 60},
|
||||
{"HDDL", 60},
|
||||
{"FPGA", 120},
|
||||
{"UNKNOWN", 120}};
|
||||
uint32_t duration = 0;
|
||||
for (const auto& deviceDurationInSeconds : deviceDefaultDurationInSeconds) {
|
||||
if (device.find(deviceDurationInSeconds.first) != std::string::npos) {
|
||||
@ -63,16 +68,18 @@ uint32_t deviceDefaultDeviceDurationInSeconds(const std::string& device) {
|
||||
}
|
||||
}
|
||||
if (duration == 0) {
|
||||
const auto unknownDeviceIt =
|
||||
find_if(deviceDefaultDurationInSeconds.begin(), deviceDefaultDurationInSeconds.end(), [](std::pair<std::string, uint32_t> deviceDuration) {
|
||||
return deviceDuration.first == "UNKNOWN";
|
||||
});
|
||||
const auto unknownDeviceIt = find_if(deviceDefaultDurationInSeconds.begin(),
|
||||
deviceDefaultDurationInSeconds.end(),
|
||||
[](std::pair<std::string, uint32_t> deviceDuration) {
|
||||
return deviceDuration.first == "UNKNOWN";
|
||||
});
|
||||
|
||||
if (unknownDeviceIt == deviceDefaultDurationInSeconds.end()) {
|
||||
throw std::logic_error("UNKNOWN device was not found in the device duration list");
|
||||
}
|
||||
duration = unknownDeviceIt->second;
|
||||
slog::warn << "Default duration " << duration << " seconds for unknown device '" << device << "' is used" << slog::endl;
|
||||
slog::warn << "Default duration " << duration << " seconds for unknown device '" << device << "' is used"
|
||||
<< slog::endl;
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
@ -112,7 +119,8 @@ std::vector<std::string> parseDevices(const std::string& device_string) {
|
||||
return devices;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector<std::string>& devices, const std::string& values_string) {
|
||||
std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector<std::string>& devices,
|
||||
const std::string& values_string) {
|
||||
// Format: <device1>:<value1>,<device2>:<value2> or just <value>
|
||||
std::map<std::string, std::string> result;
|
||||
auto device_value_strings = split(values_string, ',');
|
||||
@ -125,7 +133,8 @@ std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector
|
||||
if (it != devices.end()) {
|
||||
result[device_name] = nstreams;
|
||||
} else {
|
||||
throw std::logic_error("Can't set nstreams value " + std::string(nstreams) + " for device '" + device_name + "'! Incorrect device name!");
|
||||
throw std::logic_error("Can't set nstreams value " + std::string(nstreams) + " for device '" +
|
||||
device_name + "'! Incorrect device name!");
|
||||
}
|
||||
} else if (device_value_vec.size() == 1) {
|
||||
auto value = device_value_vec.at(0);
|
||||
@ -172,7 +181,8 @@ std::string getShapesString(const InferenceEngine::ICNNNetwork::InputShapes& sha
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<float>> parseScaleOrMean(const std::string& scale_mean, const benchmark_app::InputsInfo& inputs_info) {
|
||||
std::map<std::string, std::vector<float>> parseScaleOrMean(const std::string& scale_mean,
|
||||
const benchmark_app::InputsInfo& inputs_info) {
|
||||
// Format: data:[255,255,255],info[255,255,255]
|
||||
std::map<std::string, std::vector<float>> return_value;
|
||||
|
||||
|
@ -29,14 +29,17 @@ using InputsInfo = std::map<std::string, InputInfo>;
|
||||
|
||||
std::vector<std::string> parseDevices(const std::string& device_string);
|
||||
uint32_t deviceDefaultDeviceDurationInSeconds(const std::string& device);
|
||||
std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector<std::string>& devices, const std::string& values_string);
|
||||
std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector<std::string>& devices,
|
||||
const std::string& values_string);
|
||||
std::string getShapesString(const InferenceEngine::ICNNNetwork::InputShapes& shapes);
|
||||
size_t getBatchSize(const benchmark_app::InputsInfo& inputs_info);
|
||||
std::vector<std::string> split(const std::string& s, char delim);
|
||||
std::map<std::string, std::vector<float>> parseScaleOrMean(const std::string& scale_mean, const benchmark_app::InputsInfo& inputs_info);
|
||||
std::map<std::string, std::vector<float>> parseScaleOrMean(const std::string& scale_mean,
|
||||
const benchmark_app::InputsInfo& inputs_info);
|
||||
|
||||
template <typename T>
|
||||
std::map<std::string, std::string> parseInputParameters(const std::string parameter_string, const std::map<std::string, T>& input_info) {
|
||||
std::map<std::string, std::string> parseInputParameters(const std::string parameter_string,
|
||||
const std::map<std::string, T>& input_info) {
|
||||
// Parse parameter string like "input0[value0],input1[value1]" or "[value]" (applied to all
|
||||
// inputs)
|
||||
std::map<std::string, std::string> return_value;
|
||||
@ -67,8 +70,12 @@ std::map<std::string, std::string> parseInputParameters(const std::string parame
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
benchmark_app::InputsInfo getInputsInfo(const std::string& shape_string, const std::string& layout_string, const size_t batch_size,
|
||||
const std::string& scale_string, const std::string& mean_string, const std::map<std::string, T>& input_info,
|
||||
benchmark_app::InputsInfo getInputsInfo(const std::string& shape_string,
|
||||
const std::string& layout_string,
|
||||
const size_t batch_size,
|
||||
const std::string& scale_string,
|
||||
const std::string& mean_string,
|
||||
const std::map<std::string, T>& input_info,
|
||||
bool& reshape_required) {
|
||||
std::map<std::string, std::string> shape_map = parseInputParameters(shape_string, input_info);
|
||||
std::map<std::string, std::string> layout_map = parseInputParameters(layout_string, input_info);
|
||||
@ -134,10 +141,20 @@ benchmark_app::InputsInfo getInputsInfo(const std::string& shape_string, const s
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
benchmark_app::InputsInfo getInputsInfo(const std::string& shape_string, const std::string& layout_string, const size_t batch_size,
|
||||
const std::string& scale_string, const std::string& mean_string, const std::map<std::string, T>& input_info) {
|
||||
benchmark_app::InputsInfo getInputsInfo(const std::string& shape_string,
|
||||
const std::string& layout_string,
|
||||
const size_t batch_size,
|
||||
const std::string& scale_string,
|
||||
const std::string& mean_string,
|
||||
const std::map<std::string, T>& input_info) {
|
||||
bool reshape_required = false;
|
||||
return getInputsInfo<T>(shape_string, layout_string, batch_size, scale_string, mean_string, input_info, reshape_required);
|
||||
return getInputsInfo<T>(shape_string,
|
||||
layout_string,
|
||||
batch_size,
|
||||
scale_string,
|
||||
mean_string,
|
||||
input_info,
|
||||
reshape_required);
|
||||
}
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
|
@ -17,13 +17,15 @@ static const char help_message[] = "Print a usage message.";
|
||||
static const char model_message[] = "Required. Path to an .xml file with a trained model.";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char image_message[] = "Required. Path to a folder with images or path to an image files: a .ubyte file for LeNet"
|
||||
" and a .bmp file for the other networks.";
|
||||
static const char image_message[] =
|
||||
"Required. Path to a folder with images or path to an image files: a .ubyte file for LeNet"
|
||||
" and a .bmp file for the other networks.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] = "Optional. Specify the target device to infer on (the list of available devices is shown below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify the target device to infer on (the list of available devices is shown below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for top results number
|
||||
static const char ntop_message[] = "Optional. Number of top results. Default value is 10.";
|
||||
|
@ -100,7 +100,8 @@ int main(int argc, char* argv[]) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie.SetConfig({{PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c}}, FLAGS_d);
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c << slog::endl;
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c
|
||||
<< slog::endl;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -142,8 +143,8 @@ int main(int argc, char* argv[]) {
|
||||
continue;
|
||||
}
|
||||
/** Store image data **/
|
||||
std::shared_ptr<unsigned char> data(
|
||||
reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3], inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
std::shared_ptr<unsigned char> data(reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3],
|
||||
inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
if (data != nullptr) {
|
||||
imagesData.push_back(data);
|
||||
validImageNames.push_back(i);
|
||||
@ -203,7 +204,8 @@ int main(int argc, char* argv[]) {
|
||||
for (size_t ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in
|
||||
* bytes **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] = imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,8 +257,9 @@ int main(int argc, char* argv[]) {
|
||||
/** Validating -nt value **/
|
||||
const size_t resultsCnt = outputBlob->size() / batchSize;
|
||||
if (FLAGS_nt > resultsCnt || FLAGS_nt < 1) {
|
||||
slog::warn << "-nt " << FLAGS_nt << " is not available for this network (-nt should be less than " << resultsCnt + 1
|
||||
<< " and more than 0)\n Maximal value " << resultsCnt << " will be used." << slog::endl;
|
||||
slog::warn << "-nt " << FLAGS_nt << " is not available for this network (-nt should be less than "
|
||||
<< resultsCnt + 1 << " and more than 0)\n Maximal value " << resultsCnt
|
||||
<< " will be used." << slog::endl;
|
||||
FLAGS_nt = resultsCnt;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,8 @@ MnistUbyte::MnistUbyte(const std::string& filename) {
|
||||
n_cols = reverseInt(n_cols);
|
||||
_width = (size_t)n_cols;
|
||||
if (number_of_images > 1) {
|
||||
std::cout << "[MNIST] Warning: number_of_images in mnist file equals " << number_of_images << ". Only a first image will be read." << std::endl;
|
||||
std::cout << "[MNIST] Warning: number_of_images in mnist file equals " << number_of_images
|
||||
<< ". Only a first image will be read." << std::endl;
|
||||
}
|
||||
|
||||
size_t size = _width * _height * 1;
|
||||
|
@ -14,19 +14,19 @@
|
||||
#include <vector>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifdef IMPLEMENT_FORMAT_READER
|
||||
#define FORMAT_READER_API(type) extern "C" __declspec(dllexport) type
|
||||
#else
|
||||
#define FORMAT_READER_API(type) extern "C" type
|
||||
#endif
|
||||
# ifdef IMPLEMENT_FORMAT_READER
|
||||
# define FORMAT_READER_API(type) extern "C" __declspec(dllexport) type
|
||||
# else
|
||||
# define FORMAT_READER_API(type) extern "C" type
|
||||
# endif
|
||||
#elif (__GNUC__ >= 4)
|
||||
#ifdef IMPLEMENT_FORMAT_READER
|
||||
#define FORMAT_READER_API(type) extern "C" __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define FORMAT_READER_API(type) extern "C" type
|
||||
#endif
|
||||
# ifdef IMPLEMENT_FORMAT_READER
|
||||
# define FORMAT_READER_API(type) extern "C" __attribute__((visibility("default"))) type
|
||||
# else
|
||||
# define FORMAT_READER_API(type) extern "C" type
|
||||
# endif
|
||||
#else
|
||||
#define FORMAT_READER_API(TYPE) extern "C" TYPE
|
||||
# define FORMAT_READER_API(TYPE) extern "C" TYPE
|
||||
#endif
|
||||
|
||||
namespace FormatReader {
|
||||
|
@ -16,7 +16,7 @@
|
||||
namespace FormatReader {
|
||||
class ReaderPtr {
|
||||
public:
|
||||
explicit ReaderPtr(const char* imageName): reader(CreateFormatReader(imageName)) {}
|
||||
explicit ReaderPtr(const char* imageName) : reader(CreateFormatReader(imageName)) {}
|
||||
/**
|
||||
* @brief dereference operator overload
|
||||
* @return Reader
|
||||
|
@ -3,12 +3,12 @@
|
||||
//
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
#include "opencv_wrapper.h"
|
||||
# include "opencv_wrapper.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <samples/slog.hpp>
|
||||
# include <fstream>
|
||||
# include <iostream>
|
||||
# include <opencv2/opencv.hpp>
|
||||
# include <samples/slog.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace FormatReader;
|
||||
@ -32,7 +32,8 @@ std::shared_ptr<unsigned char> OCVReader::getData(size_t width = 0, size_t heigh
|
||||
size_t iw = img.size().width;
|
||||
size_t ih = img.size().height;
|
||||
if (width != iw || height != ih) {
|
||||
slog::warn << "Image is resized from (" << iw << ", " << ih << ") to (" << width << ", " << height << ")" << slog::endl;
|
||||
slog::warn << "Image is resized from (" << iw << ", " << ih << ") to (" << width << ", " << height << ")"
|
||||
<< slog::endl;
|
||||
}
|
||||
cv::resize(img, resized, cv::Size(width, height));
|
||||
}
|
||||
|
@ -9,13 +9,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
#include <format_reader.h>
|
||||
# include <format_reader.h>
|
||||
|
||||
#include <memory>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <string>
|
||||
# include <memory>
|
||||
# include <opencv2/opencv.hpp>
|
||||
# include <string>
|
||||
|
||||
#include "register.h"
|
||||
# include "register.h"
|
||||
|
||||
namespace FormatReader {
|
||||
/**
|
||||
|
@ -27,8 +27,14 @@ void readInputFilesArguments(std::vector<std::string>& files, const std::string&
|
||||
*/
|
||||
void parseInputFilesArguments(std::vector<std::string>& files);
|
||||
|
||||
void processPrecision(InferenceEngine::CNNNetwork& network, const std::string& ip, const std::string& op, const std::string& iop);
|
||||
void processPrecision(InferenceEngine::CNNNetwork& network,
|
||||
const std::string& ip,
|
||||
const std::string& op,
|
||||
const std::string& iop);
|
||||
|
||||
void processLayout(InferenceEngine::CNNNetwork& network, const std::string& il, const std::string& ol, const std::string& iol);
|
||||
void processLayout(InferenceEngine::CNNNetwork& network,
|
||||
const std::string& il,
|
||||
const std::string& ol,
|
||||
const std::string& iol);
|
||||
|
||||
void printInputAndOutputsInfo(const InferenceEngine::CNNNetwork& network);
|
||||
|
@ -78,9 +78,12 @@ private:
|
||||
batchData += offset;
|
||||
|
||||
std::iota(std::begin(indexes), std::end(indexes), 0);
|
||||
std::partial_sort(std::begin(indexes), std::begin(indexes) + n, std::end(indexes), [&batchData](unsigned l, unsigned r) {
|
||||
return batchData[l] > batchData[r];
|
||||
});
|
||||
std::partial_sort(std::begin(indexes),
|
||||
std::begin(indexes) + n,
|
||||
std::end(indexes),
|
||||
[&batchData](unsigned l, unsigned r) {
|
||||
return batchData[l] > batchData[r];
|
||||
});
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
output.at(i * n + j) = indexes.at(j);
|
||||
}
|
||||
@ -123,7 +126,10 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
explicit ClassificationResultT(InferenceEngine::Blob::Ptr output_blob, std::vector<strType> image_names = {}, size_t batch_size = 1, size_t num_of_top = 10,
|
||||
explicit ClassificationResultT(InferenceEngine::Blob::Ptr output_blob,
|
||||
std::vector<strType> image_names = {},
|
||||
size_t batch_size = 1,
|
||||
size_t num_of_top = 10,
|
||||
std::vector<std::string> labels = {})
|
||||
: _nTop(num_of_top),
|
||||
_outBlob(std::move(output_blob)),
|
||||
@ -164,8 +170,8 @@ public:
|
||||
// locked memory holder should be alive all time while access to its buffer happens
|
||||
const auto result =
|
||||
moutputHolder
|
||||
.as<const InferenceEngine::PrecisionTrait<InferenceEngine::Precision::FP32>::value_type*>()[_results.at(id) +
|
||||
image_id * (_outBlob->size() / _batchSize)];
|
||||
.as<const InferenceEngine::PrecisionTrait<InferenceEngine::Precision::FP32>::value_type*>()
|
||||
[_results.at(id) + image_id * (_outBlob->size() / _batchSize)];
|
||||
|
||||
std::cout << std::setw(static_cast<int>(_classidStr.length())) << std::left << _results.at(id) << " ";
|
||||
std::cout << std::left << std::setw(static_cast<int>(_probabilityStr.length())) << std::fixed << result;
|
||||
|
@ -24,11 +24,11 @@
|
||||
#include <vector>
|
||||
|
||||
#ifndef UNUSED
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define UNUSED
|
||||
#else
|
||||
#define UNUSED __attribute__((unused))
|
||||
#endif
|
||||
# if defined(_MSC_VER) && !defined(__clang__)
|
||||
# define UNUSED
|
||||
# else
|
||||
# define UNUSED __attribute__((unused))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -46,7 +46,8 @@ inline void ltrim(std::string& s) {
|
||||
* @param s - string to trim
|
||||
*/
|
||||
inline void rtrim(std::string& s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||
s.erase(std::find_if(s.rbegin(),
|
||||
s.rend(),
|
||||
[](int c) {
|
||||
return !std::isspace(c);
|
||||
})
|
||||
@ -130,7 +131,7 @@ public:
|
||||
* @param g - value for green channel
|
||||
* @param b - value for blue channel
|
||||
*/
|
||||
Color(unsigned char r, unsigned char g, unsigned char b): _r(r), _g(g), _b(b) {}
|
||||
Color(unsigned char r, unsigned char g, unsigned char b) : _r(r), _g(g), _b(b) {}
|
||||
|
||||
inline unsigned char red() {
|
||||
return _r;
|
||||
@ -157,9 +158,11 @@ public:
|
||||
static UNUSED void writeOutputBmp(std::vector<std::vector<size_t>> data, size_t classesNum, std::ostream& outFile) {
|
||||
unsigned int seed = (unsigned int)time(NULL);
|
||||
// Known colors for training classes from Cityscape dataset
|
||||
static std::vector<Color> colors = {{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190}, {153, 153, 153}, {30, 170, 250},
|
||||
{0, 220, 220}, {35, 142, 107}, {152, 251, 152}, {180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0},
|
||||
{70, 0, 0}, {100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111}, {81, 0, 81}};
|
||||
static std::vector<Color> colors = {
|
||||
{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190}, {153, 153, 153},
|
||||
{30, 170, 250}, {0, 220, 220}, {35, 142, 107}, {152, 251, 152}, {180, 130, 70}, {60, 20, 220},
|
||||
{0, 0, 255}, {142, 0, 0}, {70, 0, 0}, {100, 60, 0}, {90, 0, 0}, {230, 0, 0},
|
||||
{32, 11, 119}, {0, 74, 111}, {81, 0, 81}};
|
||||
|
||||
while (classesNum > colors.size()) {
|
||||
static std::mt19937 rng(seed);
|
||||
@ -171,13 +174,17 @@ static UNUSED void writeOutputBmp(std::vector<std::vector<size_t>> data, size_t
|
||||
unsigned char file[14] = {
|
||||
'B',
|
||||
'M', // magic
|
||||
0, 0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, // size in bytes
|
||||
0,
|
||||
0, // app data
|
||||
0,
|
||||
0, // app data
|
||||
40 + 14, 0, 0,
|
||||
40 + 14,
|
||||
0,
|
||||
0,
|
||||
0 // start of data offset
|
||||
};
|
||||
unsigned char info[40] = {
|
||||
@ -262,13 +269,17 @@ static UNUSED bool writeOutputBmp(std::string name, unsigned char* data, size_t
|
||||
unsigned char file[14] = {
|
||||
'B',
|
||||
'M', // magic
|
||||
0, 0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, // size in bytes
|
||||
0,
|
||||
0, // app data
|
||||
0,
|
||||
0, // app data
|
||||
40 + 14, 0, 0,
|
||||
40 + 14,
|
||||
0,
|
||||
0,
|
||||
0 // start of data offset
|
||||
};
|
||||
unsigned char info[40] = {
|
||||
@ -342,11 +353,18 @@ static UNUSED bool writeOutputBmp(std::string name, unsigned char* data, size_t
|
||||
* @param classes - vector of classes
|
||||
* @param thickness - thickness of a line (in pixels) to be used for bounding boxes
|
||||
*/
|
||||
static UNUSED void addRectangles(unsigned char* data, size_t height, size_t width, std::vector<int> rectangles, std::vector<int> classes, int thickness = 1) {
|
||||
static UNUSED void addRectangles(unsigned char* data,
|
||||
size_t height,
|
||||
size_t width,
|
||||
std::vector<int> rectangles,
|
||||
std::vector<int> classes,
|
||||
int thickness = 1) {
|
||||
std::vector<Color> colors = {// colors to be used for bounding boxes
|
||||
{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190}, {153, 153, 153}, {30, 170, 250},
|
||||
{0, 220, 220}, {35, 142, 107}, {152, 251, 152}, {180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0},
|
||||
{70, 0, 0}, {100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111}, {81, 0, 81}};
|
||||
{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190},
|
||||
{153, 153, 153}, {30, 170, 250}, {0, 220, 220}, {35, 142, 107}, {152, 251, 152},
|
||||
{180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0}, {70, 0, 0},
|
||||
{100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111},
|
||||
{81, 0, 81}};
|
||||
if (rectangles.size() % 4 != 0 || rectangles.size() / 4 != classes.size()) {
|
||||
return;
|
||||
}
|
||||
@ -430,13 +448,17 @@ static UNUSED bool writeOutputBmp(unsigned char* data, size_t height, size_t wid
|
||||
unsigned char file[14] = {
|
||||
'B',
|
||||
'M', // magic
|
||||
0, 0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, // size in bytes
|
||||
0,
|
||||
0, // app data
|
||||
0,
|
||||
0, // app data
|
||||
40 + 14, 0, 0,
|
||||
40 + 14,
|
||||
0,
|
||||
0,
|
||||
0 // start of data offset
|
||||
};
|
||||
unsigned char info[40] = {
|
||||
@ -515,8 +537,11 @@ static std::vector<std::pair<std::string, InferenceEngine::InferenceEngineProfil
|
||||
return sorted;
|
||||
}
|
||||
|
||||
static UNUSED void printPerformanceCounts(const std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& performanceMap, std::ostream& stream,
|
||||
std::string deviceName, bool bshowHeader = true) {
|
||||
static UNUSED void printPerformanceCounts(
|
||||
const std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& performanceMap,
|
||||
std::ostream& stream,
|
||||
std::string deviceName,
|
||||
bool bshowHeader = true) {
|
||||
long long totalTime = 0;
|
||||
// Print performance counts
|
||||
if (bshowHeader) {
|
||||
@ -560,12 +585,16 @@ static UNUSED void printPerformanceCounts(const std::map<std::string, InferenceE
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
static UNUSED void printPerformanceCounts(InferenceEngine::InferRequest request, std::ostream& stream, std::string deviceName, bool bshowHeader = true) {
|
||||
static UNUSED void printPerformanceCounts(InferenceEngine::InferRequest request,
|
||||
std::ostream& stream,
|
||||
std::string deviceName,
|
||||
bool bshowHeader = true) {
|
||||
auto performanceMap = request.GetPerformanceCounts();
|
||||
printPerformanceCounts(performanceMap, stream, deviceName, bshowHeader);
|
||||
}
|
||||
|
||||
inline std::map<std::string, std::string> getMapFullDevicesNames(InferenceEngine::Core& ie, std::vector<std::string> devices) {
|
||||
inline std::map<std::string, std::string> getMapFullDevicesNames(InferenceEngine::Core& ie,
|
||||
std::vector<std::string> devices) {
|
||||
std::map<std::string, std::string> devicesMap;
|
||||
InferenceEngine::Parameter p;
|
||||
for (std::string& deviceName : devices) {
|
||||
@ -608,8 +637,20 @@ public:
|
||||
float xmin, xmax, ymin, ymax, prob;
|
||||
bool difficult;
|
||||
|
||||
DetectedObject(int _objectType, float _xmin, float _ymin, float _xmax, float _ymax, float _prob, bool _difficult = false)
|
||||
: objectType(_objectType), xmin(_xmin), xmax(_xmax), ymin(_ymin), ymax(_ymax), prob(_prob), difficult(_difficult) {}
|
||||
DetectedObject(int _objectType,
|
||||
float _xmin,
|
||||
float _ymin,
|
||||
float _xmax,
|
||||
float _ymax,
|
||||
float _prob,
|
||||
bool _difficult = false)
|
||||
: objectType(_objectType),
|
||||
xmin(_xmin),
|
||||
xmax(_xmax),
|
||||
ymin(_ymin),
|
||||
ymax(_ymax),
|
||||
prob(_prob),
|
||||
difficult(_difficult) {}
|
||||
|
||||
DetectedObject(const DetectedObject& other) = default;
|
||||
|
||||
@ -617,10 +658,18 @@ public:
|
||||
// Add small space to eliminate empty squares
|
||||
float epsilon = 0; // 1e-5f;
|
||||
|
||||
DetectedObject detectedObject1(detectedObject1_.objectType, (detectedObject1_.xmin - epsilon), (detectedObject1_.ymin - epsilon),
|
||||
(detectedObject1_.xmax - epsilon), (detectedObject1_.ymax - epsilon), detectedObject1_.prob);
|
||||
DetectedObject detectedObject2(detectedObject2_.objectType, (detectedObject2_.xmin + epsilon), (detectedObject2_.ymin + epsilon),
|
||||
(detectedObject2_.xmax), (detectedObject2_.ymax), detectedObject2_.prob);
|
||||
DetectedObject detectedObject1(detectedObject1_.objectType,
|
||||
(detectedObject1_.xmin - epsilon),
|
||||
(detectedObject1_.ymin - epsilon),
|
||||
(detectedObject1_.xmax - epsilon),
|
||||
(detectedObject1_.ymax - epsilon),
|
||||
detectedObject1_.prob);
|
||||
DetectedObject detectedObject2(detectedObject2_.objectType,
|
||||
(detectedObject2_.xmin + epsilon),
|
||||
(detectedObject2_.ymin + epsilon),
|
||||
(detectedObject2_.xmax),
|
||||
(detectedObject2_.ymax),
|
||||
detectedObject2_.prob);
|
||||
|
||||
if (detectedObject1.objectType != detectedObject2.objectType) {
|
||||
// objects are different, so the result is 0
|
||||
@ -657,8 +706,10 @@ public:
|
||||
}
|
||||
|
||||
// union
|
||||
float square1 = (addendum + detectedObject1.xmax - detectedObject1.xmin) * (addendum + detectedObject1.ymax - detectedObject1.ymin);
|
||||
float square2 = (addendum + detectedObject2.xmax - detectedObject2.xmin) * (addendum + detectedObject2.ymax - detectedObject2.ymin);
|
||||
float square1 = (addendum + detectedObject1.xmax - detectedObject1.xmin) *
|
||||
(addendum + detectedObject1.ymax - detectedObject1.ymin);
|
||||
float square2 = (addendum + detectedObject2.xmax - detectedObject2.xmin) *
|
||||
(addendum + detectedObject2.ymax - detectedObject2.ymin);
|
||||
|
||||
float unn = square1 + square2 - intr;
|
||||
|
||||
@ -666,7 +717,13 @@ public:
|
||||
}
|
||||
|
||||
DetectedObject scale(float scale_x, float scale_y) const {
|
||||
return DetectedObject(objectType, xmin * scale_x, ymin * scale_y, xmax * scale_x, ymax * scale_y, prob, difficult);
|
||||
return DetectedObject(objectType,
|
||||
xmin * scale_x,
|
||||
ymin * scale_y,
|
||||
xmax * scale_x,
|
||||
ymax * scale_y,
|
||||
prob,
|
||||
difficult);
|
||||
}
|
||||
};
|
||||
|
||||
@ -675,7 +732,9 @@ public:
|
||||
const std::list<DetectedObject> alist;
|
||||
const bool check_probs;
|
||||
|
||||
explicit ImageDescription(const std::list<DetectedObject>& _alist, bool _check_probs = false): alist(_alist), check_probs(_check_probs) {}
|
||||
explicit ImageDescription(const std::list<DetectedObject>& _alist, bool _check_probs = false)
|
||||
: alist(_alist),
|
||||
check_probs(_check_probs) {}
|
||||
|
||||
static float ioUMultiple(const ImageDescription& detectedObjects, const ImageDescription& desiredObjects) {
|
||||
const ImageDescription *detectedObjectsSmall, *detectedObjectsBig;
|
||||
@ -755,7 +814,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
explicit AveragePrecisionCalculator(double _threshold): threshold(_threshold) {}
|
||||
explicit AveragePrecisionCalculator(double _threshold) : threshold(_threshold) {}
|
||||
|
||||
// gt_bboxes -> des
|
||||
// bboxes -> det
|
||||
@ -763,7 +822,7 @@ public:
|
||||
void consumeImage(const ImageDescription& detectedObjects, const ImageDescription& desiredObjects) {
|
||||
// Collecting IoU values
|
||||
std::vector<bool> visited(desiredObjects.alist.size(), false);
|
||||
std::vector<DetectedObject> bboxes {std::begin(detectedObjects.alist), std::end(detectedObjects.alist)};
|
||||
std::vector<DetectedObject> bboxes{std::begin(detectedObjects.alist), std::end(detectedObjects.alist)};
|
||||
std::sort(bboxes.begin(), bboxes.end(), SortBBoxDescend);
|
||||
|
||||
for (auto&& detObj : bboxes) {
|
||||
@ -882,10 +941,15 @@ public:
|
||||
* @param width - width of the rectangle
|
||||
* @param detectedObjects - vector of detected objects
|
||||
*/
|
||||
static UNUSED void addRectangles(unsigned char* data, size_t height, size_t width, std::vector<DetectedObject> detectedObjects) {
|
||||
std::vector<Color> colors = {{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190}, {153, 153, 153}, {30, 170, 250},
|
||||
{0, 220, 220}, {35, 142, 107}, {152, 251, 152}, {180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0},
|
||||
{70, 0, 0}, {100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111}, {81, 0, 81}};
|
||||
static UNUSED void addRectangles(unsigned char* data,
|
||||
size_t height,
|
||||
size_t width,
|
||||
std::vector<DetectedObject> detectedObjects) {
|
||||
std::vector<Color> colors = {{128, 64, 128}, {232, 35, 244}, {70, 70, 70}, {156, 102, 102}, {153, 153, 190},
|
||||
{153, 153, 153}, {30, 170, 250}, {0, 220, 220}, {35, 142, 107}, {152, 251, 152},
|
||||
{180, 130, 70}, {60, 20, 220}, {0, 0, 255}, {142, 0, 0}, {70, 0, 0},
|
||||
{100, 60, 0}, {90, 0, 0}, {230, 0, 0}, {32, 11, 119}, {0, 74, 111},
|
||||
{81, 0, 81}};
|
||||
|
||||
for (size_t i = 0; i < detectedObjects.size(); i++) {
|
||||
int cls = detectedObjects[i].objectType % colors.size();
|
||||
@ -923,10 +987,11 @@ inline std::size_t getTensorWidth(const InferenceEngine::TensorDesc& desc) {
|
||||
const auto& layout = desc.getLayout();
|
||||
const auto& dims = desc.getDims();
|
||||
const auto& size = dims.size();
|
||||
if ((size >= 2) && (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC || layout == InferenceEngine::Layout::NCDHW ||
|
||||
layout == InferenceEngine::Layout::NDHWC || layout == InferenceEngine::Layout::OIHW || layout == InferenceEngine::Layout::GOIHW ||
|
||||
layout == InferenceEngine::Layout::OIDHW || layout == InferenceEngine::Layout::GOIDHW || layout == InferenceEngine::Layout::CHW ||
|
||||
layout == InferenceEngine::Layout::HW)) {
|
||||
if ((size >= 2) && (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC ||
|
||||
layout == InferenceEngine::Layout::NCDHW || layout == InferenceEngine::Layout::NDHWC ||
|
||||
layout == InferenceEngine::Layout::OIHW || layout == InferenceEngine::Layout::GOIHW ||
|
||||
layout == InferenceEngine::Layout::OIDHW || layout == InferenceEngine::Layout::GOIDHW ||
|
||||
layout == InferenceEngine::Layout::CHW || layout == InferenceEngine::Layout::HW)) {
|
||||
// Regardless of layout, dimensions are stored in fixed order
|
||||
return dims.back();
|
||||
} else {
|
||||
@ -939,10 +1004,11 @@ inline std::size_t getTensorHeight(const InferenceEngine::TensorDesc& desc) {
|
||||
const auto& layout = desc.getLayout();
|
||||
const auto& dims = desc.getDims();
|
||||
const auto& size = dims.size();
|
||||
if ((size >= 2) && (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC || layout == InferenceEngine::Layout::NCDHW ||
|
||||
layout == InferenceEngine::Layout::NDHWC || layout == InferenceEngine::Layout::OIHW || layout == InferenceEngine::Layout::GOIHW ||
|
||||
layout == InferenceEngine::Layout::OIDHW || layout == InferenceEngine::Layout::GOIDHW || layout == InferenceEngine::Layout::CHW ||
|
||||
layout == InferenceEngine::Layout::HW)) {
|
||||
if ((size >= 2) && (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC ||
|
||||
layout == InferenceEngine::Layout::NCDHW || layout == InferenceEngine::Layout::NDHWC ||
|
||||
layout == InferenceEngine::Layout::OIHW || layout == InferenceEngine::Layout::GOIHW ||
|
||||
layout == InferenceEngine::Layout::OIDHW || layout == InferenceEngine::Layout::GOIDHW ||
|
||||
layout == InferenceEngine::Layout::CHW || layout == InferenceEngine::Layout::HW)) {
|
||||
// Regardless of layout, dimensions are stored in fixed order
|
||||
return dims.at(size - 2);
|
||||
} else {
|
||||
@ -953,8 +1019,9 @@ inline std::size_t getTensorHeight(const InferenceEngine::TensorDesc& desc) {
|
||||
|
||||
inline std::size_t getTensorChannels(const InferenceEngine::TensorDesc& desc) {
|
||||
const auto& layout = desc.getLayout();
|
||||
if (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC || layout == InferenceEngine::Layout::NCDHW ||
|
||||
layout == InferenceEngine::Layout::NDHWC || layout == InferenceEngine::Layout::C || layout == InferenceEngine::Layout::CHW ||
|
||||
if (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC ||
|
||||
layout == InferenceEngine::Layout::NCDHW || layout == InferenceEngine::Layout::NDHWC ||
|
||||
layout == InferenceEngine::Layout::C || layout == InferenceEngine::Layout::CHW ||
|
||||
layout == InferenceEngine::Layout::NC || layout == InferenceEngine::Layout::CN) {
|
||||
// Regardless of layout, dimensions are stored in fixed order
|
||||
const auto& dims = desc.getDims();
|
||||
@ -982,8 +1049,9 @@ inline std::size_t getTensorChannels(const InferenceEngine::TensorDesc& desc) {
|
||||
|
||||
inline std::size_t getTensorBatch(const InferenceEngine::TensorDesc& desc) {
|
||||
const auto& layout = desc.getLayout();
|
||||
if (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC || layout == InferenceEngine::Layout::NCDHW ||
|
||||
layout == InferenceEngine::Layout::NDHWC || layout == InferenceEngine::Layout::NC || layout == InferenceEngine::Layout::CN) {
|
||||
if (layout == InferenceEngine::Layout::NCHW || layout == InferenceEngine::Layout::NHWC ||
|
||||
layout == InferenceEngine::Layout::NCDHW || layout == InferenceEngine::Layout::NDHWC ||
|
||||
layout == InferenceEngine::Layout::NC || layout == InferenceEngine::Layout::CN) {
|
||||
// Regardless of layout, dimensions are stored in fixed order
|
||||
const auto& dims = desc.getDims();
|
||||
switch (desc.getLayoutByDims(dims)) {
|
||||
|
@ -29,9 +29,13 @@ public:
|
||||
* @param _total - maximum value that is correspondent to 100%
|
||||
* @param _detalization - number of symbols(.) to use to represent progress
|
||||
*/
|
||||
explicit ConsoleProgress(size_t _total, bool _stream_output = false, size_t _percent_to_update = DEFAULT_PERCENT_TO_UPDATE_PROGRESS,
|
||||
explicit ConsoleProgress(size_t _total,
|
||||
bool _stream_output = false,
|
||||
size_t _percent_to_update = DEFAULT_PERCENT_TO_UPDATE_PROGRESS,
|
||||
size_t _detalization = DEFAULT_DETALIZATION)
|
||||
: total(_total), detalization(_detalization), percent_to_update(_percent_to_update) {
|
||||
: total(_total),
|
||||
detalization(_detalization),
|
||||
percent_to_update(_percent_to_update) {
|
||||
stream_output = _stream_output;
|
||||
if (total == 0) {
|
||||
total = 1;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
* @param enabled - True if dumping is enabled by default.
|
||||
* @param name - name of file to dump to. File won't be created if first parameter is false.
|
||||
*/
|
||||
explicit CsvDumper(bool enabled = true, const std::string& name = ""): canDump(enabled) {
|
||||
explicit CsvDumper(bool enabled = true, const std::string& name = "") : canDump(enabled) {
|
||||
if (!canDump) {
|
||||
return;
|
||||
}
|
||||
|
@ -70,7 +70,9 @@ static UNUSED InferenceEngine::Blob::Ptr wrapMat2Blob(const cv::Mat& mat) {
|
||||
if (!is_dense)
|
||||
IE_THROW() << "Doesn't support conversion from not dense cv::Mat";
|
||||
|
||||
InferenceEngine::TensorDesc tDesc(InferenceEngine::Precision::U8, {1, channels, height, width}, InferenceEngine::Layout::NHWC);
|
||||
InferenceEngine::TensorDesc tDesc(InferenceEngine::Precision::U8,
|
||||
{1, channels, height, width},
|
||||
InferenceEngine::Layout::NHWC);
|
||||
|
||||
return InferenceEngine::make_shared_blob<uint8_t>(tDesc, mat.data);
|
||||
}
|
||||
|
@ -6,43 +6,43 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN_UNDEF
|
||||
#endif
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# endif
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#define NOMINMAX_UNDEF
|
||||
#endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# define NOMINMAX_UNDEF
|
||||
# endif
|
||||
|
||||
#if defined(_M_IX86) && !defined(_X86_) && !defined(_AMD64_)
|
||||
#define _X86_
|
||||
#endif
|
||||
# if defined(_M_IX86) && !defined(_X86_) && !defined(_AMD64_)
|
||||
# define _X86_
|
||||
# endif
|
||||
|
||||
#if defined(_M_X64) && !defined(_X86_) && !defined(_AMD64_)
|
||||
#define _AMD64_
|
||||
#endif
|
||||
# if defined(_M_X64) && !defined(_X86_) && !defined(_AMD64_)
|
||||
# define _AMD64_
|
||||
# endif
|
||||
|
||||
#if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
#define _ARM_
|
||||
#endif
|
||||
# if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
# define _ARM_
|
||||
# endif
|
||||
|
||||
#if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
#define _ARM64_
|
||||
#endif
|
||||
# if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
# define _ARM64_
|
||||
# endif
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
#include <string.h>
|
||||
#include <windef.h>
|
||||
#include <fileapi.h>
|
||||
#include <Winbase.h>
|
||||
#include <sys/stat.h>
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
|
||||
// Copied from linux libc sys/stat.h:
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
// Copied from linux libc sys/stat.h:
|
||||
# define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
|
||||
/// @brief structure to store directory names
|
||||
struct dirent {
|
||||
@ -79,7 +79,7 @@ public:
|
||||
DIR& operator=(const DIR& other) = delete;
|
||||
DIR& operator=(DIR&& other) = delete;
|
||||
|
||||
explicit DIR(const char* dirPath): next(nullptr) {
|
||||
explicit DIR(const char* dirPath) : next(nullptr) {
|
||||
std::string ws = dirPath;
|
||||
if (endsWith(ws, "\\"))
|
||||
ws += "*";
|
||||
@ -158,19 +158,19 @@ static void closedir(DIR* dp) {
|
||||
delete dp;
|
||||
}
|
||||
|
||||
#ifdef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
#endif
|
||||
# ifdef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# undef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# endif
|
||||
|
||||
#ifdef NOMINMAX_UNDEF
|
||||
#undef NOMINMAX_UNDEF
|
||||
#undef NOMINMAX
|
||||
#endif
|
||||
# ifdef NOMINMAX_UNDEF
|
||||
# undef NOMINMAX_UNDEF
|
||||
# undef NOMINMAX
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
# include <dirent.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
#endif
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include <samples/slog.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <samples/os/windows/w_dirent.h>
|
||||
# include <samples/os/windows/w_dirent.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -142,10 +142,18 @@ InferenceEngine::Precision getPrecision(std::string value, const supported_preci
|
||||
|
||||
InferenceEngine::Precision getPrecision(const std::string& value) {
|
||||
static const supported_precisions_t supported_precisions = {
|
||||
{"FP32", InferenceEngine::Precision::FP32}, {"FP16", InferenceEngine::Precision::FP16}, {"BF16", InferenceEngine::Precision::BF16},
|
||||
{"U64", InferenceEngine::Precision::U64}, {"I64", InferenceEngine::Precision::I64}, {"U32", InferenceEngine::Precision::U32},
|
||||
{"I32", InferenceEngine::Precision::I32}, {"U16", InferenceEngine::Precision::U16}, {"I16", InferenceEngine::Precision::I16},
|
||||
{"U8", InferenceEngine::Precision::U8}, {"I8", InferenceEngine::Precision::I8}, {"BOOL", InferenceEngine::Precision::BOOL},
|
||||
{"FP32", InferenceEngine::Precision::FP32},
|
||||
{"FP16", InferenceEngine::Precision::FP16},
|
||||
{"BF16", InferenceEngine::Precision::BF16},
|
||||
{"U64", InferenceEngine::Precision::U64},
|
||||
{"I64", InferenceEngine::Precision::I64},
|
||||
{"U32", InferenceEngine::Precision::U32},
|
||||
{"I32", InferenceEngine::Precision::I32},
|
||||
{"U16", InferenceEngine::Precision::U16},
|
||||
{"I16", InferenceEngine::Precision::I16},
|
||||
{"U8", InferenceEngine::Precision::U8},
|
||||
{"I8", InferenceEngine::Precision::I8},
|
||||
{"BOOL", InferenceEngine::Precision::BOOL},
|
||||
};
|
||||
|
||||
return getPrecision(value, supported_precisions);
|
||||
@ -176,7 +184,10 @@ void setPrecisions(const InferenceEngine::CNNNetwork& network, const std::string
|
||||
|
||||
} // namespace
|
||||
|
||||
void processPrecision(InferenceEngine::CNNNetwork& network, const std::string& ip, const std::string& op, const std::string& iop) {
|
||||
void processPrecision(InferenceEngine::CNNNetwork& network,
|
||||
const std::string& ip,
|
||||
const std::string& op,
|
||||
const std::string& iop) {
|
||||
if (!ip.empty()) {
|
||||
const auto user_precision = getPrecision(ip);
|
||||
for (auto&& layer : network.getInputsInfo()) {
|
||||
@ -213,20 +224,27 @@ InferenceEngine::Layout getLayout(std::string value, const supported_layouts_t&
|
||||
|
||||
InferenceEngine::Layout getLayout(const std::string& value) {
|
||||
static const supported_layouts_t supported_layouts = {
|
||||
{"NCDHW", InferenceEngine::Layout::NCDHW}, {"NDHWC", InferenceEngine::Layout::NDHWC}, {"NCHW", InferenceEngine::Layout::NCHW},
|
||||
{"NHWC", InferenceEngine::Layout::NHWC}, {"CHW", InferenceEngine::Layout::CHW}, {"HWC", InferenceEngine::Layout::HWC},
|
||||
{"NC", InferenceEngine::Layout::NC}, {"C", InferenceEngine::Layout::C},
|
||||
{"NCDHW", InferenceEngine::Layout::NCDHW},
|
||||
{"NDHWC", InferenceEngine::Layout::NDHWC},
|
||||
{"NCHW", InferenceEngine::Layout::NCHW},
|
||||
{"NHWC", InferenceEngine::Layout::NHWC},
|
||||
{"CHW", InferenceEngine::Layout::CHW},
|
||||
{"HWC", InferenceEngine::Layout::HWC},
|
||||
{"NC", InferenceEngine::Layout::NC},
|
||||
{"C", InferenceEngine::Layout::C},
|
||||
};
|
||||
|
||||
return getLayout(value, supported_layouts);
|
||||
}
|
||||
|
||||
bool isMatchLayoutToDims(InferenceEngine::Layout layout, size_t dimension) {
|
||||
static const matchLayoutToDims_t matchLayoutToDims = {
|
||||
{static_cast<size_t>(InferenceEngine::Layout::NCDHW), 5}, {static_cast<size_t>(InferenceEngine::Layout::NDHWC), 5},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::NCHW), 4}, {static_cast<size_t>(InferenceEngine::Layout::NHWC), 4},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::CHW), 3}, {static_cast<size_t>(InferenceEngine::Layout::NC), 2},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::C), 1}};
|
||||
static const matchLayoutToDims_t matchLayoutToDims = {{static_cast<size_t>(InferenceEngine::Layout::NCDHW), 5},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::NDHWC), 5},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::NCHW), 4},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::NHWC), 4},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::CHW), 3},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::NC), 2},
|
||||
{static_cast<size_t>(InferenceEngine::Layout::C), 1}};
|
||||
|
||||
const auto dims = matchLayoutToDims.find(static_cast<size_t>(layout));
|
||||
if (dims == matchLayoutToDims.end()) {
|
||||
@ -269,7 +287,10 @@ void setLayouts(const InferenceEngine::CNNNetwork& network, const std::string io
|
||||
|
||||
} // namespace
|
||||
|
||||
void processLayout(InferenceEngine::CNNNetwork& network, const std::string& il, const std::string& ol, const std::string& iol) {
|
||||
void processLayout(InferenceEngine::CNNNetwork& network,
|
||||
const std::string& il,
|
||||
const std::string& ol,
|
||||
const std::string& iol) {
|
||||
if (!il.empty()) {
|
||||
const auto layout = getLayout(il);
|
||||
for (auto&& layer : network.getInputsInfo()) {
|
||||
@ -296,10 +317,12 @@ void processLayout(InferenceEngine::CNNNetwork& network, const std::string& il,
|
||||
void printInputAndOutputsInfo(const InferenceEngine::CNNNetwork& network) {
|
||||
std::cout << "Network inputs:" << std::endl;
|
||||
for (auto&& layer : network.getInputsInfo()) {
|
||||
std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / " << layer.second->getLayout() << std::endl;
|
||||
std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / "
|
||||
<< layer.second->getLayout() << std::endl;
|
||||
}
|
||||
std::cout << "Network outputs:" << std::endl;
|
||||
for (auto&& layer : network.getOutputsInfo()) {
|
||||
std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / " << layer.second->getLayout() << std::endl;
|
||||
std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / "
|
||||
<< layer.second->getLayout() << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ LogStream info("INFO", std::cout);
|
||||
LogStream warn("WARNING", std::cout);
|
||||
LogStream err("ERROR", std::cerr);
|
||||
|
||||
LogStream::LogStream(const std::string& prefix, std::ostream& log_stream): _prefix(prefix), _new_line(true) {
|
||||
LogStream::LogStream(const std::string& prefix, std::ostream& log_stream) : _prefix(prefix), _new_line(true) {
|
||||
_log_stream = &log_stream;
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,15 @@ using namespace InferenceEngine;
|
||||
* @brief Define names based depends on Unicode path support
|
||||
*/
|
||||
#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
|
||||
#define tcout std::wcout
|
||||
#define file_name_t std::wstring
|
||||
#define imread_t imreadW
|
||||
#define ClassificationResult_t ClassificationResultW
|
||||
# define tcout std::wcout
|
||||
# define file_name_t std::wstring
|
||||
# define imread_t imreadW
|
||||
# define ClassificationResult_t ClassificationResultW
|
||||
#else
|
||||
#define tcout std::cout
|
||||
#define file_name_t std::string
|
||||
#define imread_t cv::imread
|
||||
#define ClassificationResult_t ClassificationResult
|
||||
# define tcout std::cout
|
||||
# define file_name_t std::string
|
||||
# define imread_t cv::imread
|
||||
# define ClassificationResult_t ClassificationResult
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
|
||||
@ -43,7 +43,9 @@ cv::Mat imreadW(std::wstring input_image_path) {
|
||||
std::size_t file_size = input_image_stream.tellg();
|
||||
input_image_stream.seekg(0, std::ios::beg);
|
||||
std::vector<char> buffer(0);
|
||||
std::copy(std::istreambuf_iterator<char>(input_image_stream), std::istreambuf_iterator<char>(), std::back_inserter(buffer));
|
||||
std::copy(std::istreambuf_iterator<char>(input_image_stream),
|
||||
std::istreambuf_iterator<char>(),
|
||||
std::back_inserter(buffer));
|
||||
image = cv::imdecode(cv::Mat(1, file_size, CV_8UC1, &buffer[0]), cv::IMREAD_COLOR);
|
||||
} else {
|
||||
tcout << "Input file '" << input_image_path << "' processing error" << std::endl;
|
||||
@ -83,12 +85,12 @@ int main(int argc, char* argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const file_name_t input_model {argv[1]};
|
||||
const file_name_t input_image_path {argv[2]};
|
||||
const file_name_t input_model{argv[1]};
|
||||
const file_name_t input_image_path{argv[2]};
|
||||
#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
|
||||
const std::string device_name = simpleConvert(argv[3]);
|
||||
#else
|
||||
const std::string device_name {argv[3]};
|
||||
const std::string device_name{argv[3]};
|
||||
#endif
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#ifdef _WIN32
|
||||
#include <samples/os/windows/w_dirent.h>
|
||||
# include <samples/os/windows/w_dirent.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
using namespace InferenceEngine;
|
||||
@ -147,8 +147,12 @@ std::vector<Blob::Ptr> readInputBlobs(std::vector<UString>& data, size_t width,
|
||||
// logical height
|
||||
|
||||
// Create tensor descriptors for Y and UV blobs
|
||||
const InferenceEngine::TensorDesc y_plane_desc(InferenceEngine::Precision::U8, {1, 1, height, width}, InferenceEngine::Layout::NHWC);
|
||||
const InferenceEngine::TensorDesc uv_plane_desc(InferenceEngine::Precision::U8, {1, 2, height / 2, width / 2}, InferenceEngine::Layout::NHWC);
|
||||
const InferenceEngine::TensorDesc y_plane_desc(InferenceEngine::Precision::U8,
|
||||
{1, 1, height, width},
|
||||
InferenceEngine::Layout::NHWC);
|
||||
const InferenceEngine::TensorDesc uv_plane_desc(InferenceEngine::Precision::U8,
|
||||
{1, 2, height / 2, width / 2},
|
||||
InferenceEngine::Layout::NHWC);
|
||||
const size_t offset = width * height;
|
||||
|
||||
std::vector<Blob::Ptr> blobs;
|
||||
@ -177,13 +181,15 @@ std::vector<Blob::Ptr> readInputBlobs(std::vector<UString>& data, size_t width,
|
||||
bool isBatchedBlobSupported(const Core& ie, const std::string& device_name) {
|
||||
const std::vector<std::string> supported_metrics = ie.GetMetric(device_name, METRIC_KEY(SUPPORTED_METRICS));
|
||||
|
||||
if (std::find(supported_metrics.begin(), supported_metrics.end(), METRIC_KEY(OPTIMIZATION_CAPABILITIES)) == supported_metrics.end()) {
|
||||
if (std::find(supported_metrics.begin(), supported_metrics.end(), METRIC_KEY(OPTIMIZATION_CAPABILITIES)) ==
|
||||
supported_metrics.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<std::string> optimization_caps = ie.GetMetric(device_name, METRIC_KEY(OPTIMIZATION_CAPABILITIES));
|
||||
|
||||
return std::find(optimization_caps.begin(), optimization_caps.end(), METRIC_VALUE(BATCHED_BLOB)) != optimization_caps.end();
|
||||
return std::find(optimization_caps.begin(), optimization_caps.end(), METRIC_VALUE(BATCHED_BLOB)) !=
|
||||
optimization_caps.end();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,15 +200,16 @@ int main(int argc, char* argv[]) {
|
||||
// ------------------------------ Parsing and validation input
|
||||
// arguments------------------------------
|
||||
if (argc != 5) {
|
||||
std::cout << "Usage : " << argv[0] << " <path_to_model> <path_to_image(s)> <image_size> <device_name>" << std::endl;
|
||||
std::cout << "Usage : " << argv[0] << " <path_to_model> <path_to_image(s)> <image_size> <device_name>"
|
||||
<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const std::string input_model {argv[1]};
|
||||
const std::string input_image_path {argv[2]};
|
||||
const std::string input_model{argv[1]};
|
||||
const std::string input_image_path{argv[2]};
|
||||
size_t input_width = 0, input_height = 0;
|
||||
std::tie(input_width, input_height) = parseImageSize(argv[3]);
|
||||
const std::string device_name {argv[4]};
|
||||
const std::string device_name{argv[4]};
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------ Read image names
|
||||
|
@ -125,7 +125,8 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
if (std::find(supportedMetrics.begin(), supportedMetrics.end(), METRIC_KEY(SUPPORTED_CONFIG_KEYS)) != supportedMetrics.end()) {
|
||||
if (std::find(supportedMetrics.begin(), supportedMetrics.end(), METRIC_KEY(SUPPORTED_CONFIG_KEYS)) !=
|
||||
supportedMetrics.end()) {
|
||||
std::cout << "\tSUPPORTED_CONFIG_KEYS (default values): " << std::endl;
|
||||
std::vector<std::string> supportedConfigKeys = ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
|
||||
for (auto&& configKey : supportedConfigKeys) {
|
||||
|
@ -21,10 +21,10 @@ int main(int argc, char* argv[]) {
|
||||
std::cout << "Usage : " << argv[0] << " <path_to_model> <path_to_image> <device> <batch>" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
const std::string input_model {argv[1]};
|
||||
const std::string input_image_path {argv[2]};
|
||||
const std::string device_name {argv[3]};
|
||||
const size_t batch_size {std::stoul(argv[4])};
|
||||
const std::string input_model{argv[1]};
|
||||
const std::string input_image_path{argv[2]};
|
||||
const std::string device_name{argv[3]};
|
||||
const size_t batch_size{std::stoul(argv[4])};
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 1. Initialize inference engine core
|
||||
@ -177,8 +177,8 @@ int main(int argc, char* argv[]) {
|
||||
std::ostringstream conf;
|
||||
conf << ":" << std::fixed << std::setprecision(3) << confidence;
|
||||
cv::rectangle(image, cv::Point2f(xmin, ymin), cv::Point2f(xmax, ymax), cv::Scalar(0, 0, 255));
|
||||
std::cout << "[" << cur_proposal << "," << label << "] element, prob = " << confidence << ", bbox = (" << xmin << "," << ymin << ")-(" << xmax
|
||||
<< "," << ymax << ")"
|
||||
std::cout << "[" << cur_proposal << "," << label << "] element, prob = " << confidence << ", bbox = ("
|
||||
<< xmin << "," << ymin << ")-(" << xmax << "," << ymax << ")"
|
||||
<< ", batch id = " << image_id << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
class CustomReLUImpl : public InferenceEngine::ILayerExecImpl {
|
||||
public:
|
||||
explicit CustomReLUImpl(const std::shared_ptr<ngraph::Node>& node): _node(node) {}
|
||||
explicit CustomReLUImpl(const std::shared_ptr<ngraph::Node>& node) : _node(node) {}
|
||||
|
||||
InferenceEngine::StatusCode getSupportedConfigurations(std::vector<InferenceEngine::LayerConfig>& conf,
|
||||
InferenceEngine::ResponseDesc* /*resp*/) noexcept override {
|
||||
@ -44,15 +44,19 @@ public:
|
||||
return InferenceEngine::OK;
|
||||
}
|
||||
|
||||
InferenceEngine::StatusCode init(InferenceEngine::LayerConfig& /*config*/, InferenceEngine::ResponseDesc* /*resp*/) noexcept override {
|
||||
InferenceEngine::StatusCode init(InferenceEngine::LayerConfig& /*config*/,
|
||||
InferenceEngine::ResponseDesc* /*resp*/) noexcept override {
|
||||
return InferenceEngine::StatusCode::OK;
|
||||
}
|
||||
|
||||
InferenceEngine::StatusCode execute(std::vector<InferenceEngine::Blob::Ptr>& inputs, std::vector<InferenceEngine::Blob::Ptr>& outputs,
|
||||
InferenceEngine::StatusCode execute(std::vector<InferenceEngine::Blob::Ptr>& inputs,
|
||||
std::vector<InferenceEngine::Blob::Ptr>& outputs,
|
||||
InferenceEngine::ResponseDesc* /*resp*/) noexcept override {
|
||||
static bool wasCalled = false;
|
||||
if (!wasCalled) {
|
||||
std::cout << "Running " + std::string(CUSTOM_RELU_TYPE) + " kernel for the first time (next messages won't be printed)" << std::endl;
|
||||
std::cout << "Running " + std::string(CUSTOM_RELU_TYPE) +
|
||||
" kernel for the first time (next messages won't be printed)"
|
||||
<< std::endl;
|
||||
wasCalled = true;
|
||||
}
|
||||
for (size_t i = 0; i < inputs.size(); i++) {
|
||||
@ -80,13 +84,13 @@ private:
|
||||
|
||||
class CustomReluOp : public ngraph::op::Op {
|
||||
public:
|
||||
static constexpr ngraph::NodeTypeInfo type_info {CUSTOM_RELU_TYPE, 0};
|
||||
static constexpr ngraph::NodeTypeInfo type_info{CUSTOM_RELU_TYPE, 0};
|
||||
const ngraph::NodeTypeInfo& get_type_info() const override {
|
||||
return type_info;
|
||||
}
|
||||
|
||||
CustomReluOp() = default;
|
||||
explicit CustomReluOp(const ngraph::Output<ngraph::Node>& arg): Op({arg}) {
|
||||
explicit CustomReluOp(const ngraph::Output<ngraph::Node>& arg) : Op({arg}) {
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
|
||||
@ -134,7 +138,8 @@ public:
|
||||
return {"CPU"};
|
||||
}
|
||||
|
||||
InferenceEngine::ILayerImpl::Ptr getImplementation(const std::shared_ptr<ngraph::Node>& node, const std::string& implType) override {
|
||||
InferenceEngine::ILayerImpl::Ptr getImplementation(const std::shared_ptr<ngraph::Node>& node,
|
||||
const std::string& implType) override {
|
||||
if (impls.find(node->description()) == impls.end() || implType != "CPU")
|
||||
return nullptr;
|
||||
return impls[node->description()](node);
|
||||
|
@ -113,107 +113,151 @@ std::shared_ptr<Function> createNgraphFunction() {
|
||||
"classification network.";
|
||||
|
||||
// -------input------
|
||||
std::vector<ptrdiff_t> padBegin {0, 0};
|
||||
std::vector<ptrdiff_t> padEnd {0, 0};
|
||||
std::vector<ptrdiff_t> padBegin{0, 0};
|
||||
std::vector<ptrdiff_t> padEnd{0, 0};
|
||||
|
||||
auto paramNode = std::make_shared<op::Parameter>(element::Type_t::f32, Shape(std::vector<size_t> {{64, 1, 28, 28}}));
|
||||
auto paramNode = std::make_shared<op::Parameter>(element::Type_t::f32, Shape(std::vector<size_t>{{64, 1, 28, 28}}));
|
||||
paramNode->set_friendly_name("Parameter");
|
||||
|
||||
// -------convolution 1----
|
||||
auto convFirstShape = Shape {20, 1, 5, 5};
|
||||
auto convFirstShape = Shape{20, 1, 5, 5};
|
||||
std::shared_ptr<Node> convolutionFirstConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, convFirstShape, weightsPtr->cbuffer().as<uint8_t*>());
|
||||
|
||||
std::shared_ptr<Node> convolutionNodeFirst =
|
||||
std::make_shared<op::v1::Convolution>(paramNode->output(0), convolutionFirstConstantNode->output(0), Strides(SizeVector {1, 1}),
|
||||
CoordinateDiff(padBegin), CoordinateDiff(padEnd), Strides(SizeVector {1, 1}));
|
||||
std::make_shared<op::v1::Convolution>(paramNode->output(0),
|
||||
convolutionFirstConstantNode->output(0),
|
||||
Strides(SizeVector{1, 1}),
|
||||
CoordinateDiff(padBegin),
|
||||
CoordinateDiff(padEnd),
|
||||
Strides(SizeVector{1, 1}));
|
||||
|
||||
// -------Add--------------
|
||||
auto addFirstShape = Shape {1, 20, 1, 1};
|
||||
auto addFirstShape = Shape{1, 20, 1, 1};
|
||||
auto offset = shape_size(convFirstShape) * sizeof(float);
|
||||
std::shared_ptr<Node> addFirstConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, addFirstShape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
addFirstShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> addNodeFirst = std::make_shared<op::v1::Add>(convolutionNodeFirst->output(0), addFirstConstantNode->output(0));
|
||||
std::shared_ptr<Node> addNodeFirst =
|
||||
std::make_shared<op::v1::Add>(convolutionNodeFirst->output(0), addFirstConstantNode->output(0));
|
||||
|
||||
// -------MAXPOOL----------
|
||||
Shape padBeginShape {0, 0};
|
||||
Shape padEndShape {0, 0};
|
||||
Shape padBeginShape{0, 0};
|
||||
Shape padEndShape{0, 0};
|
||||
|
||||
std::shared_ptr<Node> maxPoolingNodeFirst =
|
||||
std::make_shared<op::v1::MaxPool>(addNodeFirst->output(0), std::vector<size_t> {2, 2}, padBeginShape, padEndShape, std::vector<size_t> {2, 2},
|
||||
op::RoundingType::CEIL, op::PadType::EXPLICIT);
|
||||
std::shared_ptr<Node> maxPoolingNodeFirst = std::make_shared<op::v1::MaxPool>(addNodeFirst->output(0),
|
||||
std::vector<size_t>{2, 2},
|
||||
padBeginShape,
|
||||
padEndShape,
|
||||
std::vector<size_t>{2, 2},
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::EXPLICIT);
|
||||
|
||||
// -------convolution 2----
|
||||
auto convSecondShape = Shape {50, 20, 5, 5};
|
||||
auto convSecondShape = Shape{50, 20, 5, 5};
|
||||
offset += shape_size(addFirstShape) * sizeof(float);
|
||||
std::shared_ptr<Node> convolutionSecondConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, convSecondShape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
convSecondShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> convolutionNodeSecond =
|
||||
std::make_shared<op::v1::Convolution>(maxPoolingNodeFirst->output(0), convolutionSecondConstantNode->output(0), Strides({1, 1}),
|
||||
CoordinateDiff(padBegin), CoordinateDiff(padEnd), Strides({1, 1}));
|
||||
std::make_shared<op::v1::Convolution>(maxPoolingNodeFirst->output(0),
|
||||
convolutionSecondConstantNode->output(0),
|
||||
Strides({1, 1}),
|
||||
CoordinateDiff(padBegin),
|
||||
CoordinateDiff(padEnd),
|
||||
Strides({1, 1}));
|
||||
|
||||
// -------Add 2------------
|
||||
auto addSecondShape = Shape {1, 50, 1, 1};
|
||||
auto addSecondShape = Shape{1, 50, 1, 1};
|
||||
offset += shape_size(convSecondShape) * sizeof(float);
|
||||
std::shared_ptr<Node> addSecondConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, addSecondShape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
addSecondShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> addNodeSecond = std::make_shared<op::v1::Add>(convolutionNodeSecond->output(0), addSecondConstantNode->output(0));
|
||||
std::shared_ptr<Node> addNodeSecond =
|
||||
std::make_shared<op::v1::Add>(convolutionNodeSecond->output(0), addSecondConstantNode->output(0));
|
||||
|
||||
// -------MAXPOOL 2--------
|
||||
std::shared_ptr<Node> maxPoolingNodeSecond = std::make_shared<op::v1::MaxPool>(addNodeSecond->output(0), Strides {2, 2}, padBeginShape, padEndShape,
|
||||
Shape {2, 2}, op::RoundingType::CEIL, op::PadType::EXPLICIT);
|
||||
std::shared_ptr<Node> maxPoolingNodeSecond = std::make_shared<op::v1::MaxPool>(addNodeSecond->output(0),
|
||||
Strides{2, 2},
|
||||
padBeginShape,
|
||||
padEndShape,
|
||||
Shape{2, 2},
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::EXPLICIT);
|
||||
|
||||
// -------Reshape----------
|
||||
auto reshapeFirstShape = Shape {2};
|
||||
auto reshapeFirstShape = Shape{2};
|
||||
auto reshapeOffset = shape_size(addSecondShape) * sizeof(float) + offset;
|
||||
std::shared_ptr<Node> reshapeFirstConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::i64, reshapeFirstShape, (weightsPtr->cbuffer().as<uint8_t*>() + reshapeOffset));
|
||||
std::make_shared<op::Constant>(element::Type_t::i64,
|
||||
reshapeFirstShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + reshapeOffset));
|
||||
|
||||
std::shared_ptr<Node> reshapeFirstNode = std::make_shared<op::v1::Reshape>(maxPoolingNodeSecond->output(0), reshapeFirstConstantNode->output(0), true);
|
||||
std::shared_ptr<Node> reshapeFirstNode =
|
||||
std::make_shared<op::v1::Reshape>(maxPoolingNodeSecond->output(0), reshapeFirstConstantNode->output(0), true);
|
||||
|
||||
// -------MatMul 1---------
|
||||
auto matMulFirstShape = Shape {500, 800};
|
||||
auto matMulFirstShape = Shape{500, 800};
|
||||
offset = shape_size(reshapeFirstShape) * sizeof(int64_t) + reshapeOffset;
|
||||
std::shared_ptr<Node> matMulFirstConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, matMulFirstShape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
matMulFirstShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> matMulFirstNode = std::make_shared<op::MatMul>(reshapeFirstNode->output(0), matMulFirstConstantNode->output(0), false, true);
|
||||
std::shared_ptr<Node> matMulFirstNode =
|
||||
std::make_shared<op::MatMul>(reshapeFirstNode->output(0), matMulFirstConstantNode->output(0), false, true);
|
||||
|
||||
// -------Add 3------------
|
||||
auto addThirdShape = Shape {1, 500};
|
||||
auto addThirdShape = Shape{1, 500};
|
||||
offset += shape_size(matMulFirstShape) * sizeof(float);
|
||||
std::shared_ptr<Node> addThirdConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, addThirdShape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
addThirdShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> addThirdNode = std::make_shared<op::v1::Add>(matMulFirstNode->output(0), addThirdConstantNode->output(0));
|
||||
std::shared_ptr<Node> addThirdNode =
|
||||
std::make_shared<op::v1::Add>(matMulFirstNode->output(0), addThirdConstantNode->output(0));
|
||||
|
||||
// -------Relu-------------
|
||||
std::shared_ptr<Node> reluNode = std::make_shared<op::Relu>(addThirdNode->output(0));
|
||||
|
||||
// -------Reshape 2--------
|
||||
auto reshapeSecondShape = Shape {2};
|
||||
auto reshapeSecondShape = Shape{2};
|
||||
std::shared_ptr<Node> reshapeSecondConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::i64, reshapeSecondShape, (weightsPtr->cbuffer().as<uint8_t*>() + reshapeOffset));
|
||||
std::make_shared<op::Constant>(element::Type_t::i64,
|
||||
reshapeSecondShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + reshapeOffset));
|
||||
|
||||
std::shared_ptr<Node> reshapeSecondNode = std::make_shared<op::v1::Reshape>(reluNode->output(0), reshapeSecondConstantNode->output(0), true);
|
||||
std::shared_ptr<Node> reshapeSecondNode =
|
||||
std::make_shared<op::v1::Reshape>(reluNode->output(0), reshapeSecondConstantNode->output(0), true);
|
||||
|
||||
// -------MatMul 2---------
|
||||
auto matMulSecondShape = Shape {10, 500};
|
||||
auto matMulSecondShape = Shape{10, 500};
|
||||
offset += shape_size(addThirdShape) * sizeof(float);
|
||||
std::shared_ptr<Node> matMulSecondConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32, matMulSecondShape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
matMulSecondShape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> matMulSecondNode = std::make_shared<op::MatMul>(reshapeSecondNode->output(0), matMulSecondConstantNode->output(0), false, true);
|
||||
std::shared_ptr<Node> matMulSecondNode =
|
||||
std::make_shared<op::MatMul>(reshapeSecondNode->output(0), matMulSecondConstantNode->output(0), false, true);
|
||||
|
||||
// -------Add 4------------
|
||||
auto add4Shape = Shape {1, 10};
|
||||
auto add4Shape = Shape{1, 10};
|
||||
offset += shape_size(matMulSecondShape) * sizeof(float);
|
||||
std::shared_ptr<Node> add4ConstantNode = std::make_shared<op::Constant>(element::Type_t::f32, add4Shape, (weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
std::shared_ptr<Node> add4ConstantNode =
|
||||
std::make_shared<op::Constant>(element::Type_t::f32,
|
||||
add4Shape,
|
||||
(weightsPtr->cbuffer().as<uint8_t*>() + offset));
|
||||
|
||||
std::shared_ptr<Node> add4Node = std::make_shared<op::v1::Add>(matMulSecondNode->output(0), add4ConstantNode->output(0));
|
||||
std::shared_ptr<Node> add4Node =
|
||||
std::make_shared<op::v1::Add>(matMulSecondNode->output(0), add4ConstantNode->output(0));
|
||||
|
||||
// -------softMax----------
|
||||
std::shared_ptr<Node> softMaxNode = std::make_shared<op::v1::Softmax>(add4Node->output(0), 1);
|
||||
@ -221,7 +265,8 @@ std::shared_ptr<Function> createNgraphFunction() {
|
||||
// -------ngraph function--
|
||||
auto result_full = std::make_shared<op::Result>(softMaxNode->output(0));
|
||||
|
||||
std::shared_ptr<ngraph::Function> fnPtr = std::make_shared<ngraph::Function>(result_full, ngraph::ParameterVector {paramNode}, "lenet");
|
||||
std::shared_ptr<ngraph::Function> fnPtr =
|
||||
std::make_shared<ngraph::Function>(result_full, ngraph::ParameterVector{paramNode}, "lenet");
|
||||
|
||||
return fnPtr;
|
||||
}
|
||||
@ -294,8 +339,8 @@ int main(int argc, char* argv[]) {
|
||||
continue;
|
||||
}
|
||||
/** Store image data **/
|
||||
std::shared_ptr<unsigned char> data(
|
||||
reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3], inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
std::shared_ptr<unsigned char> data(reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3],
|
||||
inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
if (data.get() != nullptr) {
|
||||
imagesData.push_back(data);
|
||||
}
|
||||
@ -384,7 +429,8 @@ int main(int argc, char* argv[]) {
|
||||
for (size_t ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in
|
||||
* bytes **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] = imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -407,8 +453,9 @@ int main(int argc, char* argv[]) {
|
||||
/** Validating -nt value **/
|
||||
const size_t resultsCnt = outputBlob->size() / batchSize;
|
||||
if (FLAGS_nt > resultsCnt || FLAGS_nt < 1) {
|
||||
slog::warn << "-nt " << FLAGS_nt << " is not available for this network (-nt should be less than " << resultsCnt + 1
|
||||
<< " and more than 0).\n Maximal value " << resultsCnt << " will be used.";
|
||||
slog::warn << "-nt " << FLAGS_nt << " is not available for this network (-nt should be less than "
|
||||
<< resultsCnt + 1 << " and more than 0).\n Maximal value " << resultsCnt
|
||||
<< " will be used.";
|
||||
FLAGS_nt = resultsCnt;
|
||||
}
|
||||
|
||||
|
@ -14,15 +14,17 @@
|
||||
static const char help_message[] = "Print a usage message.";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char input_message[] = "Required. Path to a folder with images or path to image files. Support ubyte files only.";
|
||||
static const char input_message[] =
|
||||
"Required. Path to a folder with images or path to image files. Support ubyte files only.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char model_message[] = "Required. Path to a .bin file with weights for the trained model.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] = "Optional. Specify the target device to infer on (the list of available devices is shown below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify the target device to infer on (the list of available devices is shown below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for top results number
|
||||
static const char ntop_message[] = "Number of top results. The default value is 10.";
|
||||
|
@ -100,7 +100,8 @@ int main(int argc, char* argv[]) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie.SetConfig({{PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c}}, FLAGS_d);
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c << slog::endl;
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c
|
||||
<< slog::endl;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -157,7 +158,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
Precision inputPrecision = Precision::FP32;
|
||||
item.second->setPrecision(inputPrecision);
|
||||
if ((item.second->getTensorDesc().getDims()[1] != 3 && item.second->getTensorDesc().getDims()[1] != 6)) {
|
||||
if ((item.second->getTensorDesc().getDims()[1] != 3 &&
|
||||
item.second->getTensorDesc().getDims()[1] != 6)) {
|
||||
throw std::logic_error("Invalid input info. Should be 3 or 6 values length");
|
||||
}
|
||||
}
|
||||
@ -182,7 +184,8 @@ int main(int argc, char* argv[]) {
|
||||
if (auto ngraphFunction = network.getFunction()) {
|
||||
for (const auto& out : outputsInfo) {
|
||||
for (const auto& op : ngraphFunction->get_ops()) {
|
||||
if (op->get_type_info() == ngraph::op::DetectionOutput::type_info && op->get_friendly_name() == out.second->getName()) {
|
||||
if (op->get_type_info() == ngraph::op::DetectionOutput::type_info &&
|
||||
op->get_friendly_name() == out.second->getName()) {
|
||||
outputName = out.first;
|
||||
outputInfo = out.second;
|
||||
break;
|
||||
@ -239,7 +242,8 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
/** Store image data **/
|
||||
std::shared_ptr<unsigned char> originalData(reader->getData());
|
||||
std::shared_ptr<unsigned char> data(reader->getData(inputInfo->getTensorDesc().getDims()[3], inputInfo->getTensorDesc().getDims()[2]));
|
||||
std::shared_ptr<unsigned char> data(
|
||||
reader->getData(inputInfo->getTensorDesc().getDims()[3], inputInfo->getTensorDesc().getDims()[2]));
|
||||
if (data.get() != nullptr) {
|
||||
originalImagesData.push_back(originalData);
|
||||
imagesData.push_back(data);
|
||||
@ -253,7 +257,9 @@ int main(int argc, char* argv[]) {
|
||||
size_t batchSize = network.getBatchSize();
|
||||
slog::info << "Batch size is " << std::to_string(batchSize) << slog::endl;
|
||||
if (batchSize != imagesData.size()) {
|
||||
slog::warn << "Number of images " + std::to_string(imagesData.size()) + " doesn't match batch size " + std::to_string(batchSize) << slog::endl;
|
||||
slog::warn << "Number of images " + std::to_string(imagesData.size()) + " doesn't match batch size " +
|
||||
std::to_string(batchSize)
|
||||
<< slog::endl;
|
||||
batchSize = std::min(batchSize, imagesData.size());
|
||||
slog::warn << "Number of images to be processed is " << std::to_string(batchSize) << slog::endl;
|
||||
}
|
||||
@ -288,7 +294,8 @@ int main(int argc, char* argv[]) {
|
||||
for (size_t ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in
|
||||
* bytes **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] = imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,8 +319,10 @@ int main(int argc, char* argv[]) {
|
||||
float* p = minput2Holder.as<PrecisionTrait<Precision::FP32>::value_type*>();
|
||||
|
||||
for (size_t image_id = 0; image_id < std::min(imagesData.size(), batchSize); ++image_id) {
|
||||
p[image_id * imInfoDim + 0] = static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[2]);
|
||||
p[image_id * imInfoDim + 1] = static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[3]);
|
||||
p[image_id * imInfoDim + 0] =
|
||||
static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[2]);
|
||||
p[image_id * imInfoDim + 1] =
|
||||
static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[3]);
|
||||
for (size_t k = 2; k < imInfoDim; k++) {
|
||||
p[image_id * imInfoDim + k] = 1.0f; // all scale factors are set to 1.0
|
||||
}
|
||||
@ -359,8 +368,8 @@ int main(int argc, char* argv[]) {
|
||||
auto xmax = static_cast<int>(detection[curProposal * objectSize + 5] * imageWidths[image_id]);
|
||||
auto ymax = static_cast<int>(detection[curProposal * objectSize + 6] * imageHeights[image_id]);
|
||||
|
||||
std::cout << "[" << curProposal << "," << label << "] element, prob = " << confidence << " (" << xmin << "," << ymin << ")-(" << xmax << ","
|
||||
<< ymax << ")"
|
||||
std::cout << "[" << curProposal << "," << label << "] element, prob = " << confidence << " (" << xmin
|
||||
<< "," << ymin << ")-(" << xmax << "," << ymax << ")"
|
||||
<< " batch id : " << image_id;
|
||||
|
||||
if (confidence > 0.5) {
|
||||
@ -376,10 +385,17 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
for (size_t batch_id = 0; batch_id < batchSize; ++batch_id) {
|
||||
addRectangles(originalImagesData[batch_id].get(), imageHeights[batch_id], imageWidths[batch_id], boxes[batch_id], classes[batch_id],
|
||||
addRectangles(originalImagesData[batch_id].get(),
|
||||
imageHeights[batch_id],
|
||||
imageWidths[batch_id],
|
||||
boxes[batch_id],
|
||||
classes[batch_id],
|
||||
BBOX_THICKNESS);
|
||||
const std::string image_path = "out_" + std::to_string(batch_id) + ".bmp";
|
||||
if (writeOutputBmp(image_path, originalImagesData[batch_id].get(), imageHeights[batch_id], imageWidths[batch_id])) {
|
||||
if (writeOutputBmp(image_path,
|
||||
originalImagesData[batch_id].get(),
|
||||
imageHeights[batch_id],
|
||||
imageWidths[batch_id])) {
|
||||
slog::info << "Image " + image_path + " created!" << slog::endl;
|
||||
} else {
|
||||
throw std::logic_error(std::string("Can't create a file: ") + image_path);
|
||||
|
@ -23,11 +23,12 @@ static const char model_message[] = "Required. Path to an .xml file with a train
|
||||
static const char image_message[] = "Required. Path to an image.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] = "Optional. Specify the target device to infer on (the list of available devices is shown "
|
||||
"below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify the target device to infer on (the list of available devices is shown "
|
||||
"below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for plugin custom kernels desc
|
||||
static const char custom_plugin_cfg_message[] = "Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
|
@ -4,7 +4,10 @@
|
||||
|
||||
#include "fileutils.hpp"
|
||||
|
||||
void ArkFile::GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) {
|
||||
void ArkFile::GetFileInfo(const char* fileName,
|
||||
uint32_t numArrayToFindSize,
|
||||
uint32_t* ptrNumArrays,
|
||||
uint32_t* ptrNumMemoryBytes) {
|
||||
uint32_t numArrays = 0;
|
||||
uint32_t numMemoryBytes = 0;
|
||||
|
||||
@ -40,8 +43,13 @@ void ArkFile::GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uin
|
||||
*ptrNumMemoryBytes = numMemoryBytes;
|
||||
}
|
||||
|
||||
void ArkFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement) {
|
||||
void ArkFile::LoadFile(const char* fileName,
|
||||
uint32_t arrayIndex,
|
||||
std::string& ptrName,
|
||||
std::vector<uint8_t>& memory,
|
||||
uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns,
|
||||
uint32_t* ptrNumBytesPerElement) {
|
||||
std::ifstream in_file(fileName, std::ios::binary);
|
||||
if (in_file.good()) {
|
||||
uint32_t i = 0;
|
||||
@ -64,7 +72,8 @@ void ArkFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string& p
|
||||
std::getline(in_file, ptrName, '\0'); // read variable length name followed by space and NUL
|
||||
std::getline(in_file, line, '\4'); // read "BFM" followed by space and control-D
|
||||
if (line.compare("BFM ") != 0) {
|
||||
throw std::runtime_error(std::string("Cannot find array specifier in file %s in LoadFile()!\n") + fileName);
|
||||
throw std::runtime_error(std::string("Cannot find array specifier in file %s in LoadFile()!\n") +
|
||||
fileName);
|
||||
}
|
||||
in_file.read(reinterpret_cast<char*>(ptrNumRows), sizeof(uint32_t)); // read number of rows
|
||||
std::getline(in_file, line, '\4'); // read control-D
|
||||
@ -80,7 +89,12 @@ void ArkFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string& p
|
||||
*ptrNumBytesPerElement = sizeof(float);
|
||||
}
|
||||
|
||||
void ArkFile::SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) {
|
||||
void ArkFile::SaveFile(const char* fileName,
|
||||
bool shouldAppend,
|
||||
std::string name,
|
||||
void* ptrMemory,
|
||||
uint32_t numRows,
|
||||
uint32_t numColumns) {
|
||||
std::ios_base::openmode mode = std::ios::binary;
|
||||
if (shouldAppend) {
|
||||
mode |= std::ios::app;
|
||||
@ -101,7 +115,10 @@ void ArkFile::SaveFile(const char* fileName, bool shouldAppend, std::string name
|
||||
}
|
||||
}
|
||||
|
||||
void NumpyFile::GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) {
|
||||
void NumpyFile::GetFileInfo(const char* fileName,
|
||||
uint32_t numArrayToFindSize,
|
||||
uint32_t* ptrNumArrays,
|
||||
uint32_t* ptrNumMemoryBytes) {
|
||||
uint32_t numArrays = 0;
|
||||
uint32_t numMemoryBytes = 0;
|
||||
|
||||
@ -122,8 +139,13 @@ void NumpyFile::GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, u
|
||||
}
|
||||
}
|
||||
|
||||
void NumpyFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement) {
|
||||
void NumpyFile::LoadFile(const char* fileName,
|
||||
uint32_t arrayIndex,
|
||||
std::string& ptrName,
|
||||
std::vector<uint8_t>& memory,
|
||||
uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns,
|
||||
uint32_t* ptrNumBytesPerElement) {
|
||||
cnpy::npz_t my_npz1 = cnpy::npz_load(fileName);
|
||||
auto it = my_npz1.begin();
|
||||
std::advance(it, arrayIndex);
|
||||
@ -143,9 +165,14 @@ void NumpyFile::LoadFile(const char* fileName, uint32_t arrayIndex, std::string&
|
||||
}
|
||||
}
|
||||
|
||||
void NumpyFile::SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) {
|
||||
void NumpyFile::SaveFile(const char* fileName,
|
||||
bool shouldAppend,
|
||||
std::string name,
|
||||
void* ptrMemory,
|
||||
uint32_t numRows,
|
||||
uint32_t numColumns) {
|
||||
std::string mode;
|
||||
shouldAppend ? mode = "a" : mode = "w";
|
||||
std::vector<size_t> shape {numRows, numColumns};
|
||||
std::vector<size_t> shape{numRows, numColumns};
|
||||
cnpy::npz_save(fileName, name, reinterpret_cast<float*>(ptrMemory), shape, mode);
|
||||
}
|
||||
|
@ -11,12 +11,25 @@
|
||||
/// @brief Interface to work with files like input and output
|
||||
class BaseFile {
|
||||
public:
|
||||
virtual void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement) = 0;
|
||||
virtual void LoadFile(const char* fileName,
|
||||
uint32_t arrayIndex,
|
||||
std::string& ptrName,
|
||||
std::vector<uint8_t>& memory,
|
||||
uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns,
|
||||
uint32_t* ptrNumBytesPerElement) = 0;
|
||||
|
||||
virtual void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) = 0;
|
||||
virtual void SaveFile(const char* fileName,
|
||||
bool shouldAppend,
|
||||
std::string name,
|
||||
void* ptrMemory,
|
||||
uint32_t numRows,
|
||||
uint32_t numColumns) = 0;
|
||||
|
||||
virtual void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) = 0;
|
||||
virtual void GetFileInfo(const char* fileName,
|
||||
uint32_t numArrayToFindSize,
|
||||
uint32_t* ptrNumArrays,
|
||||
uint32_t* ptrNumMemoryBytes) = 0;
|
||||
};
|
||||
|
||||
/// @brief Responsible to work with .ark files
|
||||
@ -30,7 +43,10 @@ public:
|
||||
* @param ptrNumMemoryBytes pointer to specific number of memory bytes
|
||||
* @return none.
|
||||
*/
|
||||
void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) override;
|
||||
void GetFileInfo(const char* fileName,
|
||||
uint32_t numArrayToFindSize,
|
||||
uint32_t* ptrNumArrays,
|
||||
uint32_t* ptrNumMemoryBytes) override;
|
||||
|
||||
/**
|
||||
* @brief Load Kaldi ARK speech feature vector file
|
||||
@ -43,7 +59,12 @@ public:
|
||||
* @param ptrNumBytesPerElement pointer to number bytes per element (size of float by default)
|
||||
* @return none.
|
||||
*/
|
||||
void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows, uint32_t* ptrNumColumns,
|
||||
void LoadFile(const char* fileName,
|
||||
uint32_t arrayIndex,
|
||||
std::string& ptrName,
|
||||
std::vector<uint8_t>& memory,
|
||||
uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns,
|
||||
uint32_t* ptrNumBytesPerElement) override;
|
||||
|
||||
/**
|
||||
@ -56,7 +77,12 @@ public:
|
||||
* @param numColumns number of columns
|
||||
* @return none.
|
||||
*/
|
||||
void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) override;
|
||||
void SaveFile(const char* fileName,
|
||||
bool shouldAppend,
|
||||
std::string name,
|
||||
void* ptrMemory,
|
||||
uint32_t numRows,
|
||||
uint32_t numColumns) override;
|
||||
};
|
||||
|
||||
/// @brief Responsible to work with .npz files
|
||||
@ -70,7 +96,10 @@ public:
|
||||
* @param ptrNumMemoryBytes pointer to specific number of memory bytes
|
||||
* @return none.
|
||||
*/
|
||||
void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) override;
|
||||
void GetFileInfo(const char* fileName,
|
||||
uint32_t numArrayToFindSize,
|
||||
uint32_t* ptrNumArrays,
|
||||
uint32_t* ptrNumMemoryBytes) override;
|
||||
|
||||
/**
|
||||
* @brief Load Numpy* uncompressed NPZ speech feature vector file
|
||||
@ -83,7 +112,12 @@ public:
|
||||
* @param ptrNumBytesPerElement pointer to number bytes per element (size of float by default)
|
||||
* @return none.
|
||||
*/
|
||||
void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows, uint32_t* ptrNumColumns,
|
||||
void LoadFile(const char* fileName,
|
||||
uint32_t arrayIndex,
|
||||
std::string& ptrName,
|
||||
std::vector<uint8_t>& memory,
|
||||
uint32_t* ptrNumRows,
|
||||
uint32_t* ptrNumColumns,
|
||||
uint32_t* ptrNumBytesPerElement) override;
|
||||
|
||||
/**
|
||||
@ -96,5 +130,10 @@ public:
|
||||
* @param numColumns number of columns
|
||||
* @return none.
|
||||
*/
|
||||
void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) override;
|
||||
void SaveFile(const char* fileName,
|
||||
bool shouldAppend,
|
||||
std::string name,
|
||||
void* ptrMemory,
|
||||
uint32_t numRows,
|
||||
uint32_t numColumns) override;
|
||||
};
|
||||
|
@ -152,7 +152,11 @@ void UpdateScoreError(score_error_t* error, score_error_t* totalError) {
|
||||
* @param numColumns - number columns in score error arrays
|
||||
* @return none.
|
||||
*/
|
||||
void CompareScores(float* ptrScoreArray, void* ptrRefScoreArray, score_error_t* scoreError, uint32_t numRows, uint32_t numColumns) {
|
||||
void CompareScores(float* ptrScoreArray,
|
||||
void* ptrRefScoreArray,
|
||||
score_error_t* scoreError,
|
||||
uint32_t numRows,
|
||||
uint32_t numColumns) {
|
||||
uint32_t numErrors = 0;
|
||||
|
||||
ClearScoreError(scoreError);
|
||||
@ -194,31 +198,32 @@ void CompareScores(float* ptrScoreArray, void* ptrRefScoreArray, score_error_t*
|
||||
* @return error
|
||||
*/
|
||||
float StdDevError(score_error_t error) {
|
||||
return (sqrt(error.sumSquaredError / error.numScores - (error.sumError / error.numScores) * (error.sumError / error.numScores)));
|
||||
return (sqrt(error.sumSquaredError / error.numScores -
|
||||
(error.sumError / error.numScores) * (error.sumError / error.numScores)));
|
||||
}
|
||||
|
||||
#if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) && !defined(_M_ARM64)
|
||||
#ifdef _WIN32
|
||||
#include <intrin.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
# ifdef _WIN32
|
||||
# include <intrin.h>
|
||||
# include <windows.h>
|
||||
# else
|
||||
|
||||
#include <cpuid.h>
|
||||
# include <cpuid.h>
|
||||
|
||||
#endif
|
||||
# endif
|
||||
|
||||
inline void native_cpuid(unsigned int* eax, unsigned int* ebx, unsigned int* ecx, unsigned int* edx) {
|
||||
size_t level = *eax;
|
||||
#ifdef _WIN32
|
||||
# ifdef _WIN32
|
||||
int regs[4] = {static_cast<int>(*eax), static_cast<int>(*ebx), static_cast<int>(*ecx), static_cast<int>(*edx)};
|
||||
__cpuid(regs, level);
|
||||
*eax = static_cast<uint32_t>(regs[0]);
|
||||
*ebx = static_cast<uint32_t>(regs[1]);
|
||||
*ecx = static_cast<uint32_t>(regs[2]);
|
||||
*edx = static_cast<uint32_t>(regs[3]);
|
||||
#else
|
||||
# else
|
||||
__get_cpuid(level, eax, ebx, ecx, edx);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,8 +300,12 @@ void printReferenceCompareResults(score_error_t const& totalError, size_t frames
|
||||
* @param numberOfFramesOnHw number of frames delivered to GNA HW
|
||||
* @return none.
|
||||
*/
|
||||
void printPerformanceCounters(std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> const& utterancePerfMap, size_t numberOfFrames,
|
||||
std::ostream& stream, std::string fullDeviceName, const uint64_t numberOfFramesOnHw) {
|
||||
void printPerformanceCounters(
|
||||
std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> const& utterancePerfMap,
|
||||
size_t numberOfFrames,
|
||||
std::ostream& stream,
|
||||
std::string fullDeviceName,
|
||||
const uint64_t numberOfFramesOnHw) {
|
||||
#if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) && !defined(_M_ARM64)
|
||||
stream << std::endl << "Performance counts:" << std::endl;
|
||||
stream << std::setw(10) << std::right << ""
|
||||
@ -340,7 +349,8 @@ void printPerformanceCounters(std::map<std::string, InferenceEngine::InferenceEn
|
||||
* @param perfCounters reference to a map to save performance counters
|
||||
* @return none.
|
||||
*/
|
||||
void getPerformanceCounters(InferenceEngine::InferRequest& request, std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& perfCounters) {
|
||||
void getPerformanceCounters(InferenceEngine::InferRequest& request,
|
||||
std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& perfCounters) {
|
||||
auto retPerfCounters = request.GetPerformanceCounts();
|
||||
|
||||
for (const auto& pair : retPerfCounters) {
|
||||
@ -356,11 +366,13 @@ void getPerformanceCounters(InferenceEngine::InferRequest& request, std::map<std
|
||||
* @return none.
|
||||
*/
|
||||
void sumPerformanceCounters(std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> const& perfCounters,
|
||||
std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& totalPerfCounters, uint64_t& totalRunsOnHw) {
|
||||
std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& totalPerfCounters,
|
||||
uint64_t& totalRunsOnHw) {
|
||||
auto runOnHw = false;
|
||||
for (const auto& pair : perfCounters) {
|
||||
totalPerfCounters[pair.first].realTime_uSec += pair.second.realTime_uSec;
|
||||
runOnHw |= pair.second.realTime_uSec > 0; // if realTime is above zero, that means that a primitive was executed on the device
|
||||
runOnHw |= pair.second.realTime_uSec >
|
||||
0; // if realTime is above zero, that means that a primitive was executed on the device
|
||||
}
|
||||
totalRunsOnHw += runOnHw;
|
||||
}
|
||||
@ -380,7 +392,8 @@ std::vector<std::string> ParseScaleFactors(const std::string& str) {
|
||||
while (getline(stream, outStr, ',')) {
|
||||
auto floatScaleFactor = std::stof(outStr);
|
||||
if (floatScaleFactor <= 0.0f) {
|
||||
throw std::logic_error("Scale factor for input #" + std::to_string(i) + " (counting from zero) is out of range (must be positive).");
|
||||
throw std::logic_error("Scale factor for input #" + std::to_string(i) +
|
||||
" (counting from zero) is out of range (must be positive).");
|
||||
}
|
||||
scaleFactorInput.push_back(outStr);
|
||||
i++;
|
||||
@ -509,7 +522,8 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
*/
|
||||
int main(int argc, char* argv[]) {
|
||||
try {
|
||||
// ------------------------------ Get Inference Engine version ------------------------------------------------------
|
||||
// ------------------------------ Get Inference Engine version
|
||||
// ------------------------------------------------------
|
||||
slog::info << "InferenceEngine: " << GetInferenceEngineVersion() << slog::endl;
|
||||
|
||||
// ------------------------------ Parsing and validation of input arguments ---------------------------------
|
||||
@ -546,7 +560,8 @@ int main(int argc, char* argv[]) {
|
||||
if (numUtterances == 0) {
|
||||
numUtterances = currentNumUtterances;
|
||||
} else if (currentNumUtterances != numUtterances) {
|
||||
throw std::logic_error("Incorrect input files. Number of utterance must be the same for all input files");
|
||||
throw std::logic_error(
|
||||
"Incorrect input files. Number of utterance must be the same for all input files");
|
||||
}
|
||||
numBytesThisUtterance.push_back(currentNumBytesThisUtterance);
|
||||
}
|
||||
@ -574,7 +589,8 @@ int main(int argc, char* argv[]) {
|
||||
std::cout << ie.GetVersions(deviceStr) << std::endl;
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files)
|
||||
// --------------------------- Step 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin
|
||||
// files)
|
||||
slog::info << "Loading network files:" << slog::endl << FLAGS_m << slog::endl;
|
||||
|
||||
uint32_t batchSize = (FLAGS_cw_r > 0 || FLAGS_cw_l > 0) ? 1 : (uint32_t)FLAGS_bs;
|
||||
@ -586,7 +602,8 @@ int main(int argc, char* argv[]) {
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Set batch size ---------------------------------------------------
|
||||
/** Set batch size. Unlike in imaging, batching in time (rather than space) is done for speech recognition. **/
|
||||
/** Set batch size. Unlike in imaging, batching in time (rather than space) is done for speech recognition.
|
||||
* **/
|
||||
network.setBatchSize(batchSize);
|
||||
slog::info << "Batch size is " << std::to_string(network.getBatchSize()) << slog::endl;
|
||||
}
|
||||
@ -598,8 +615,10 @@ int main(int argc, char* argv[]) {
|
||||
std::map<std::string, std::string> gnaPluginConfig;
|
||||
std::map<std::string, std::string> genericPluginConfig;
|
||||
if (useGna) {
|
||||
std::string gnaDevice = useHetero ? FLAGS_d.substr(FLAGS_d.find("GNA"), FLAGS_d.find(",") - FLAGS_d.find("GNA")) : FLAGS_d;
|
||||
gnaPluginConfig[GNAConfigParams::KEY_GNA_DEVICE_MODE] = gnaDevice.find("_") == std::string::npos ? "GNA_AUTO" : gnaDevice;
|
||||
std::string gnaDevice =
|
||||
useHetero ? FLAGS_d.substr(FLAGS_d.find("GNA"), FLAGS_d.find(",") - FLAGS_d.find("GNA")) : FLAGS_d;
|
||||
gnaPluginConfig[GNAConfigParams::KEY_GNA_DEVICE_MODE] =
|
||||
gnaDevice.find("_") == std::string::npos ? "GNA_AUTO" : gnaDevice;
|
||||
}
|
||||
|
||||
if (FLAGS_pc) {
|
||||
@ -608,18 +627,22 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
if (FLAGS_q.compare("user") == 0) {
|
||||
if (!FLAGS_rg.empty()) {
|
||||
slog::warn << "Custom scale factor will be ignored - using scale factor from provided imported gna model: " << FLAGS_rg << slog::endl;
|
||||
slog::warn
|
||||
<< "Custom scale factor will be ignored - using scale factor from provided imported gna model: "
|
||||
<< FLAGS_rg << slog::endl;
|
||||
} else {
|
||||
auto scaleFactorInput = ParseScaleFactors(FLAGS_sf);
|
||||
if (numInputFiles != scaleFactorInput.size()) {
|
||||
std::string errMessage("Incorrect command line for multiple inputs: " + std::to_string(scaleFactorInput.size()) +
|
||||
" scale factors provided for " + std::to_string(numInputFiles) + " input files.");
|
||||
std::string errMessage(
|
||||
"Incorrect command line for multiple inputs: " + std::to_string(scaleFactorInput.size()) +
|
||||
" scale factors provided for " + std::to_string(numInputFiles) + " input files.");
|
||||
throw std::logic_error(errMessage);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < scaleFactorInput.size(); ++i) {
|
||||
slog::info << "For input " << i << " using scale factor of " << scaleFactorInput[i] << slog::endl;
|
||||
std::string scaleFactorConfigKey = GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_") + std::to_string(i);
|
||||
std::string scaleFactorConfigKey =
|
||||
GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_") + std::to_string(i);
|
||||
gnaPluginConfig[scaleFactorConfigKey] = scaleFactorInput[i];
|
||||
}
|
||||
}
|
||||
@ -635,10 +658,19 @@ int main(int argc, char* argv[]) {
|
||||
uint32_t numArrays(0), numBytes(0), numFrames(0), numFrameElements(0), numBytesPerElement(0);
|
||||
file->GetFileInfo(inputFileName, 0, &numArrays, &numBytes);
|
||||
ptrFeatures.resize(numBytes);
|
||||
file->LoadFile(inputFileName, 0, name, ptrFeatures, &numFrames, &numFrameElements, &numBytesPerElement);
|
||||
auto floatScaleFactor = ScaleFactorForQuantization(ptrFeatures.data(), MAX_VAL_2B_FEAT, numFrames * numFrameElements);
|
||||
slog::info << "Using scale factor of " << floatScaleFactor << " calculated from first utterance." << slog::endl;
|
||||
std::string scaleFactorConfigKey = GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_") + std::to_string(i);
|
||||
file->LoadFile(inputFileName,
|
||||
0,
|
||||
name,
|
||||
ptrFeatures,
|
||||
&numFrames,
|
||||
&numFrameElements,
|
||||
&numBytesPerElement);
|
||||
auto floatScaleFactor =
|
||||
ScaleFactorForQuantization(ptrFeatures.data(), MAX_VAL_2B_FEAT, numFrames * numFrameElements);
|
||||
slog::info << "Using scale factor of " << floatScaleFactor << " calculated from first utterance."
|
||||
<< slog::endl;
|
||||
std::string scaleFactorConfigKey =
|
||||
GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_") + std::to_string(i);
|
||||
gnaPluginConfig[scaleFactorConfigKey] = std::to_string(floatScaleFactor);
|
||||
}
|
||||
}
|
||||
@ -652,7 +684,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
gnaPluginConfig[GNAConfigParams::KEY_GNA_EXEC_TARGET] = FLAGS_exec_target;
|
||||
gnaPluginConfig[GNAConfigParams::KEY_GNA_COMPILE_TARGET] = FLAGS_compile_target;
|
||||
gnaPluginConfig[GNAConfigParams::KEY_GNA_LIB_N_THREADS] = std::to_string((FLAGS_cw_r > 0 || FLAGS_cw_l > 0) ? 1 : FLAGS_nthreads);
|
||||
gnaPluginConfig[GNAConfigParams::KEY_GNA_LIB_N_THREADS] =
|
||||
std::to_string((FLAGS_cw_r > 0 || FLAGS_cw_l > 0) ? 1 : FLAGS_nthreads);
|
||||
gnaPluginConfig[GNA_CONFIG_KEY(COMPACT_MODE)] = CONFIG_VALUE(NO);
|
||||
gnaPluginConfig[GNA_CONFIG_KEY(PWL_MAX_ERROR_PERCENT)] = std::to_string(FLAGS_pwl_me);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
@ -678,7 +711,8 @@ int main(int argc, char* argv[]) {
|
||||
for (const auto& outBlobName : output_names) {
|
||||
int pos_layer = outBlobName.rfind(":");
|
||||
if (pos_layer == -1) {
|
||||
throw std::logic_error(std::string("Output ") + std::string(outBlobName) + std::string(" doesn't have a port"));
|
||||
throw std::logic_error(std::string("Output ") + std::string(outBlobName) +
|
||||
std::string(" doesn't have a port"));
|
||||
}
|
||||
outputs.push_back(outBlobName.substr(0, pos_layer));
|
||||
try {
|
||||
@ -728,8 +762,9 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 3. Configure input & output --------------------------------------------------
|
||||
// This step executed after creating infer request to check input/output layers mentioned via -iname and -oname args
|
||||
// --------------------------- Step 3. Configure input & output
|
||||
// -------------------------------------------------- This step executed after creating infer request to check
|
||||
// input/output layers mentioned via -iname and -oname args
|
||||
// --------------------------- Prepare input blobs -----------------------------------------------------
|
||||
/** Taking information about all topology inputs **/
|
||||
ConstInputsDataMap cInputInfo = executableNet.GetInputsInfo();
|
||||
@ -741,8 +776,8 @@ int main(int argc, char* argv[]) {
|
||||
std::vector<std::string> inputNameBlobs = ConvertStrToVector(FLAGS_iname);
|
||||
if (inputNameBlobs.size() != cInputInfo.size()) {
|
||||
std::string errMessage(std::string("Number of network inputs ( ") + std::to_string(cInputInfo.size()) +
|
||||
" ) is not equal to the number of inputs entered in the -iname argument ( " + std::to_string(inputNameBlobs.size()) +
|
||||
" ).");
|
||||
" ) is not equal to the number of inputs entered in the -iname argument ( " +
|
||||
std::to_string(inputNameBlobs.size()) + " ).");
|
||||
throw std::logic_error(errMessage);
|
||||
}
|
||||
for (const auto& input : inputNameBlobs) {
|
||||
@ -842,9 +877,12 @@ int main(int argc, char* argv[]) {
|
||||
uint32_t numFrames(0), n(0);
|
||||
std::vector<uint32_t> numFrameElementsInput;
|
||||
|
||||
uint32_t numFramesReference(0), numFrameElementsReference(0), numBytesPerElementReference(0), numBytesReferenceScoreThisUtterance(0);
|
||||
auto dims = outputs.empty() ? cOutputInfo.rbegin()->second->getDims() : cOutputInfo[outputs[next_output]]->getDims();
|
||||
const auto numScoresPerFrame = std::accumulate(std::begin(dims), std::end(dims), size_t {1}, std::multiplies<size_t>());
|
||||
uint32_t numFramesReference(0), numFrameElementsReference(0), numBytesPerElementReference(0),
|
||||
numBytesReferenceScoreThisUtterance(0);
|
||||
auto dims = outputs.empty() ? cOutputInfo.rbegin()->second->getDims()
|
||||
: cOutputInfo[outputs[next_output]]->getDims();
|
||||
const auto numScoresPerFrame =
|
||||
std::accumulate(std::begin(dims), std::end(dims), size_t{1}, std::multiplies<size_t>());
|
||||
|
||||
slog::info << "Number scores per frame : " << numScoresPerFrame << slog::endl;
|
||||
|
||||
@ -856,13 +894,18 @@ int main(int argc, char* argv[]) {
|
||||
uint32_t currentNumFrames(0), currentNumFrameElementsInput(0), currentNumBytesPerElementInput(0);
|
||||
file->GetFileInfo(inputFilename, utteranceIndex, &n, &numBytesThisUtterance[i]);
|
||||
ptrUtterance.resize(numBytesThisUtterance[i]);
|
||||
file->LoadFile(inputFilename, utteranceIndex, uttName, ptrUtterance, ¤tNumFrames, ¤tNumFrameElementsInput,
|
||||
file->LoadFile(inputFilename,
|
||||
utteranceIndex,
|
||||
uttName,
|
||||
ptrUtterance,
|
||||
¤tNumFrames,
|
||||
¤tNumFrameElementsInput,
|
||||
¤tNumBytesPerElementInput);
|
||||
if (numFrames == 0) {
|
||||
numFrames = currentNumFrames;
|
||||
} else if (numFrames != currentNumFrames) {
|
||||
std::string errMessage("Number of frames in input files is different: " + std::to_string(numFrames) + " and " +
|
||||
std::to_string(currentNumFrames));
|
||||
std::string errMessage("Number of frames in input files is different: " +
|
||||
std::to_string(numFrames) + " and " + std::to_string(currentNumFrames));
|
||||
throw std::logic_error(errMessage);
|
||||
}
|
||||
|
||||
@ -873,7 +916,8 @@ int main(int argc, char* argv[]) {
|
||||
int i = 0;
|
||||
for (auto& ptrInputBlob : ptrInputBlobs) {
|
||||
if (ptrInputBlob->size() != numFrameElementsInput[i++] * batchSize) {
|
||||
throw std::logic_error("network input size(" + std::to_string(ptrInputBlob->size()) + ") mismatch to input file size (" +
|
||||
throw std::logic_error("network input size(" + std::to_string(ptrInputBlob->size()) +
|
||||
") mismatch to input file size (" +
|
||||
std::to_string(numFrameElementsInput[i - 1] * batchSize) + ")");
|
||||
}
|
||||
}
|
||||
@ -891,10 +935,18 @@ int main(int argc, char* argv[]) {
|
||||
throw std::logic_error("Invalid Reference Scores file");
|
||||
}
|
||||
std::string refUtteranceName;
|
||||
fileReferenceScores->GetFileInfo(reference_name_files[next_output].c_str(), utteranceIndex, &n, &numBytesReferenceScoreThisUtterance);
|
||||
fileReferenceScores->GetFileInfo(reference_name_files[next_output].c_str(),
|
||||
utteranceIndex,
|
||||
&n,
|
||||
&numBytesReferenceScoreThisUtterance);
|
||||
ptrReferenceScores.resize(numBytesReferenceScoreThisUtterance);
|
||||
fileReferenceScores->LoadFile(reference_name_files[next_output].c_str(), utteranceIndex, refUtteranceName, ptrReferenceScores,
|
||||
&numFramesReference, &numFrameElementsReference, &numBytesPerElementReference);
|
||||
fileReferenceScores->LoadFile(reference_name_files[next_output].c_str(),
|
||||
utteranceIndex,
|
||||
refUtteranceName,
|
||||
ptrReferenceScores,
|
||||
&numFramesReference,
|
||||
&numFrameElementsReference,
|
||||
&numBytesPerElementReference);
|
||||
}
|
||||
|
||||
double totalTime = 0.0;
|
||||
@ -914,7 +966,7 @@ int main(int argc, char* argv[]) {
|
||||
size_t frameIndex = 0;
|
||||
uint32_t numFramesFile = numFrames;
|
||||
numFrames += FLAGS_cw_l + FLAGS_cw_r;
|
||||
uint32_t numFramesThisBatch {batchSize};
|
||||
uint32_t numFramesThisBatch{batchSize};
|
||||
|
||||
auto t0 = Time::now();
|
||||
auto t1 = t0;
|
||||
@ -934,11 +986,13 @@ int main(int argc, char* argv[]) {
|
||||
if (frameIndex == numFrames) {
|
||||
numFramesThisBatch = 1;
|
||||
} else {
|
||||
numFramesThisBatch = (numFrames - frameIndex < batchSize) ? (numFrames - frameIndex) : batchSize;
|
||||
numFramesThisBatch =
|
||||
(numFrames - frameIndex < batchSize) ? (numFrames - frameIndex) : batchSize;
|
||||
}
|
||||
/* waits until inference result becomes available */
|
||||
if (inferRequest.frameIndex != -1) {
|
||||
StatusCode code = inferRequest.inferRequest.Wait(InferenceEngine::InferRequest::WaitMode::RESULT_READY);
|
||||
StatusCode code =
|
||||
inferRequest.inferRequest.Wait(InferenceEngine::InferRequest::WaitMode::RESULT_READY);
|
||||
|
||||
if (code != StatusCode::OK) {
|
||||
if (!useHetero)
|
||||
@ -946,23 +1000,27 @@ int main(int argc, char* argv[]) {
|
||||
if (code != StatusCode::INFER_NOT_STARTED)
|
||||
continue;
|
||||
}
|
||||
// --------------------------- Step 8. Process output part 1 -------------------------------------------------------
|
||||
// --------------------------- Step 8. Process output part 1
|
||||
// -------------------------------------------------------
|
||||
ConstOutputsDataMap newOutputInfo;
|
||||
if (inferRequest.frameIndex >= 0) {
|
||||
if (!FLAGS_o.empty()) {
|
||||
/* Prepare output data for save to file in future */
|
||||
outputFrame = &ptrScores.front() + numScoresPerFrame * sizeof(float) * (inferRequest.frameIndex);
|
||||
outputFrame = &ptrScores.front() +
|
||||
numScoresPerFrame * sizeof(float) * (inferRequest.frameIndex);
|
||||
if (!outputs.empty()) {
|
||||
newOutputInfo[outputs[next_output]] = cOutputInfo[outputs[next_output]];
|
||||
} else {
|
||||
newOutputInfo = cOutputInfo;
|
||||
}
|
||||
Blob::Ptr outputBlob = inferRequest.inferRequest.GetBlob(newOutputInfo.rbegin()->first);
|
||||
Blob::Ptr outputBlob =
|
||||
inferRequest.inferRequest.GetBlob(newOutputInfo.rbegin()->first);
|
||||
MemoryBlob::CPtr moutput = as<MemoryBlob>(outputBlob);
|
||||
|
||||
if (!moutput) {
|
||||
throw std::logic_error("We expect output to be inherited from MemoryBlob, "
|
||||
"but in fact we were not able to cast output to MemoryBlob");
|
||||
throw std::logic_error(
|
||||
"We expect output to be inherited from MemoryBlob, "
|
||||
"but in fact we were not able to cast output to MemoryBlob");
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its buffer happens
|
||||
auto moutputHolder = moutput->rmap();
|
||||
@ -976,17 +1034,23 @@ int main(int argc, char* argv[]) {
|
||||
} else {
|
||||
newOutputInfo = cOutputInfo;
|
||||
}
|
||||
Blob::Ptr outputBlob = inferRequest.inferRequest.GetBlob(newOutputInfo.rbegin()->first);
|
||||
Blob::Ptr outputBlob =
|
||||
inferRequest.inferRequest.GetBlob(newOutputInfo.rbegin()->first);
|
||||
MemoryBlob::CPtr moutput = as<MemoryBlob>(outputBlob);
|
||||
if (!moutput) {
|
||||
throw std::logic_error("We expect output to be inherited from MemoryBlob, "
|
||||
"but in fact we were not able to cast output to MemoryBlob");
|
||||
throw std::logic_error(
|
||||
"We expect output to be inherited from MemoryBlob, "
|
||||
"but in fact we were not able to cast output to MemoryBlob");
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its buffer happens
|
||||
auto moutputHolder = moutput->rmap();
|
||||
CompareScores(moutputHolder.as<float*>(),
|
||||
&ptrReferenceScores[inferRequest.frameIndex * numFrameElementsReference * numBytesPerElementReference],
|
||||
&frameError, inferRequest.numFramesThisBatch, numFrameElementsReference);
|
||||
CompareScores(
|
||||
moutputHolder.as<float*>(),
|
||||
&ptrReferenceScores[inferRequest.frameIndex * numFrameElementsReference *
|
||||
numBytesPerElementReference],
|
||||
&frameError,
|
||||
inferRequest.numFramesThisBatch,
|
||||
numFrameElementsReference);
|
||||
UpdateScoreError(&frameError, &totalError);
|
||||
}
|
||||
if (FLAGS_pc) {
|
||||
@ -1004,7 +1068,8 @@ int main(int argc, char* argv[]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// --------------------------- Step 6. Prepare input --------------------------------------------------------
|
||||
// --------------------------- Step 6. Prepare input
|
||||
// --------------------------------------------------------
|
||||
ptrInputBlobs.clear();
|
||||
if (FLAGS_iname.empty()) {
|
||||
for (auto& input : cInputInfo) {
|
||||
@ -1026,7 +1091,8 @@ int main(int argc, char* argv[]) {
|
||||
for (size_t i = 0; i < numInputFiles; ++i) {
|
||||
MemoryBlob::Ptr minput = as<MemoryBlob>(ptrInputBlobs[i]);
|
||||
if (!minput) {
|
||||
std::string errMessage("We expect ptrInputBlobs[" + std::to_string(i) + "] to be inherited from MemoryBlob, " +
|
||||
std::string errMessage("We expect ptrInputBlobs[" + std::to_string(i) +
|
||||
"] to be inherited from MemoryBlob, " +
|
||||
"but in fact we were not able to cast input blob to MemoryBlob");
|
||||
throw std::logic_error(errMessage);
|
||||
}
|
||||
@ -1050,8 +1116,9 @@ int main(int argc, char* argv[]) {
|
||||
if (idx > 0 && idx < static_cast<int>(numFramesFile)) {
|
||||
inputFrame[j] += sizeof(float) * numFrameElementsInput[j] * numFramesThisBatch;
|
||||
} else if (idx >= static_cast<int>(numFramesFile)) {
|
||||
inputFrame[j] =
|
||||
&ptrUtterances[j].front() + (numFramesFile - 1) * sizeof(float) * numFrameElementsInput[j] * numFramesThisBatch;
|
||||
inputFrame[j] = &ptrUtterances[j].front() + (numFramesFile - 1) * sizeof(float) *
|
||||
numFrameElementsInput[j] *
|
||||
numFramesThisBatch;
|
||||
} else if (idx <= 0) {
|
||||
inputFrame[j] = &ptrUtterances[j].front();
|
||||
}
|
||||
@ -1079,7 +1146,8 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 8. Process output part 2 -------------------------------------------------------
|
||||
// --------------------------- Step 8. Process output part 2
|
||||
// -------------------------------------------------------
|
||||
|
||||
if (!FLAGS_o.empty()) {
|
||||
auto exOutputScoresFile = fileExt(FLAGS_o);
|
||||
@ -1092,16 +1160,26 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
/* Save output data to file */
|
||||
bool shouldAppend = (utteranceIndex == 0) ? false : true;
|
||||
fileOutput->SaveFile(output_name_files[next_output].c_str(), shouldAppend, uttName, &ptrScores.front(), numFramesFile, numScoresPerFrame);
|
||||
fileOutput->SaveFile(output_name_files[next_output].c_str(),
|
||||
shouldAppend,
|
||||
uttName,
|
||||
&ptrScores.front(),
|
||||
numFramesFile,
|
||||
numScoresPerFrame);
|
||||
}
|
||||
|
||||
/** Show performance results **/
|
||||
std::cout << "Total time in Infer (HW and SW):\t" << totalTime << " ms" << std::endl;
|
||||
std::cout << "Frames in utterance:\t\t\t" << numFrames << " frames" << std::endl;
|
||||
std::cout << "Average Infer time per frame:\t\t" << totalTime / static_cast<double>(numFrames) << " ms" << std::endl;
|
||||
std::cout << "Average Infer time per frame:\t\t" << totalTime / static_cast<double>(numFrames) << " ms"
|
||||
<< std::endl;
|
||||
if (FLAGS_pc) {
|
||||
// print performance results
|
||||
printPerformanceCounters(utterancePerfMap, frameIndex, std::cout, getFullDeviceName(ie, FLAGS_d), totalNumberOfRunsOnHw);
|
||||
printPerformanceCounters(utterancePerfMap,
|
||||
frameIndex,
|
||||
std::cout,
|
||||
getFullDeviceName(ie, FLAGS_d),
|
||||
totalNumberOfRunsOnHw);
|
||||
}
|
||||
if (!FLAGS_r.empty()) {
|
||||
// print statistical score error
|
||||
|
@ -14,24 +14,27 @@
|
||||
static const char help_message[] = "Print a usage message.";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char input_message[] = "Required. Paths to input files. Example of usage: <file1.ark,file2.ark> or <file.ark> or <file.npz>.";
|
||||
static const char input_message[] =
|
||||
"Required. Paths to input files. Example of usage: <file1.ark,file2.ark> or <file.ark> or <file.npz>.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char model_message[] = "Required. Path to an .xml file with a trained model (required if -rg is missing).";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] = "Optional. Specify a target device to infer on. CPU, GPU, MYRIAD, GNA_AUTO, GNA_HW, "
|
||||
"GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, "
|
||||
"GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU"
|
||||
" as a secondary (e.g. HETERO:GNA,CPU) are supported. "
|
||||
"The sample will look for a suitable plugin for device specified.";
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify a target device to infer on. CPU, GPU, MYRIAD, GNA_AUTO, GNA_HW, "
|
||||
"GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, "
|
||||
"GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU"
|
||||
" as a secondary (e.g. HETERO:GNA,CPU) are supported. "
|
||||
"The sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for execution target
|
||||
static const char execution_target_message[] = "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.";
|
||||
static const char execution_target_message[] =
|
||||
"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.";
|
||||
|
||||
/// @brief message for execution target
|
||||
static const char compile_target_message[] = "Optional. Specify GNA compile target generation. "
|
||||
@ -48,34 +51,41 @@ static const char custom_cpu_library_message[] = "Required for CPU plugin custom
|
||||
"Absolute path to a shared library with the kernels implementations.";
|
||||
|
||||
/// @brief message for score output argument
|
||||
static const char output_message[] = "Optional. Output file name to save scores. Example of usage: <output.ark> or <output.npz>";
|
||||
static const char output_message[] =
|
||||
"Optional. Output file name to save scores. Example of usage: <output.ark> or <output.npz>";
|
||||
|
||||
/// @brief message for reference score file argument
|
||||
static const char reference_score_message[] = "Optional. Read reference score file and compare scores. Example of usage: <reference.ark> or <reference.npz>";
|
||||
static const char reference_score_message[] =
|
||||
"Optional. Read reference score file and compare scores. Example of usage: <reference.ark> or <reference.npz>";
|
||||
|
||||
/// @brief message for read GNA model argument
|
||||
static const char read_gna_model_message[] = "Read GNA model from file using path/filename provided (required if -m is missing).";
|
||||
static const char read_gna_model_message[] =
|
||||
"Read GNA model from file using path/filename provided (required if -m is missing).";
|
||||
|
||||
/// @brief message for write GNA model argument
|
||||
static const char write_gna_model_message[] = "Optional. Write GNA model to file using path/filename provided.";
|
||||
|
||||
/// @brief message for write GNA embedded model argument
|
||||
static const char write_embedded_model_message[] = "Optional. Write GNA embedded model to file using path/filename provided.";
|
||||
static const char write_embedded_model_message[] =
|
||||
"Optional. Write GNA embedded model to file using path/filename provided.";
|
||||
|
||||
/// @brief message for write GNA embedded model generation argument
|
||||
static const char write_embedded_model_generation_message[] = "Optional. GNA generation configuration string for embedded export."
|
||||
"Can be GNA1 (default) or GNA3.";
|
||||
static const char write_embedded_model_generation_message[] =
|
||||
"Optional. GNA generation configuration string for embedded export."
|
||||
"Can be GNA1 (default) or GNA3.";
|
||||
|
||||
/// @brief message for quantization argument
|
||||
static const char quantization_message[] = "Optional. Input quantization mode: static (default), dynamic, or user (use with -sf).";
|
||||
static const char quantization_message[] =
|
||||
"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)";
|
||||
|
||||
/// @brief message for scale factor argument
|
||||
static const char scale_factor_message[] = "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.";
|
||||
static const char scale_factor_message[] =
|
||||
"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.";
|
||||
|
||||
/// @brief message for batch size argument
|
||||
static const char batch_size_message[] = "Optional. Batch size 1-8 (default 1)";
|
||||
@ -85,14 +95,16 @@ static const char infer_num_threads_message[] = "Optional. Number of threads to
|
||||
" inference requests on the GNA.";
|
||||
|
||||
/// @brief message for left context window argument
|
||||
static const char context_window_message_l[] = "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 and nthreads arguments are ignored.";
|
||||
static const char context_window_message_l[] =
|
||||
"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 and nthreads arguments are ignored.";
|
||||
|
||||
/// @brief message for right context window argument
|
||||
static const char context_window_message_r[] = "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 and nthreads arguments are ignored.";
|
||||
static const char context_window_message_r[] =
|
||||
"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 and nthreads arguments are ignored.";
|
||||
|
||||
/// @brief message for output layer names
|
||||
static const char output_layer_names_message[] = "Optional. Layer names for output blobs. "
|
||||
|
@ -89,7 +89,8 @@ int main(int argc, char* argv[]) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie.SetConfig({{PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c}}, "GPU");
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c << slog::endl;
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c
|
||||
<< slog::endl;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -130,8 +131,8 @@ int main(int argc, char* argv[]) {
|
||||
continue;
|
||||
}
|
||||
/** Store image data **/
|
||||
std::shared_ptr<unsigned char> data(
|
||||
reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3], inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
std::shared_ptr<unsigned char> data(reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3],
|
||||
inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
if (data.get() != nullptr) {
|
||||
imagesData.push_back(data);
|
||||
}
|
||||
@ -151,7 +152,8 @@ int main(int argc, char* argv[]) {
|
||||
// BlobMap outputBlobs;
|
||||
std::string firstOutputName;
|
||||
|
||||
const float meanValues[] = {static_cast<const float>(FLAGS_mean_val_r), static_cast<const float>(FLAGS_mean_val_g),
|
||||
const float meanValues[] = {static_cast<const float>(FLAGS_mean_val_r),
|
||||
static_cast<const float>(FLAGS_mean_val_g),
|
||||
static_cast<const float>(FLAGS_mean_val_b)};
|
||||
|
||||
for (auto& item : outputInfo) {
|
||||
@ -241,16 +243,20 @@ int main(int argc, char* argv[]) {
|
||||
size_t W = moutput->getTensorDesc().getDims()[3];
|
||||
size_t nPixels = W * H;
|
||||
|
||||
slog::info << "Output size [N,C,H,W]: " << num_images << ", " << num_channels << ", " << H << ", " << W << slog::endl;
|
||||
slog::info << "Output size [N,C,H,W]: " << num_images << ", " << num_channels << ", " << H << ", " << W
|
||||
<< slog::endl;
|
||||
|
||||
{
|
||||
std::vector<float> data_img(nPixels * num_channels);
|
||||
|
||||
for (size_t n = 0; n < num_images; n++) {
|
||||
for (size_t i = 0; i < nPixels; i++) {
|
||||
data_img[i * num_channels] = static_cast<float>(output_data[i + n * nPixels * num_channels] + meanValues[0]);
|
||||
data_img[i * num_channels + 1] = static_cast<float>(output_data[(i + nPixels) + n * nPixels * num_channels] + meanValues[1]);
|
||||
data_img[i * num_channels + 2] = static_cast<float>(output_data[(i + 2 * nPixels) + n * nPixels * num_channels] + meanValues[2]);
|
||||
data_img[i * num_channels] =
|
||||
static_cast<float>(output_data[i + n * nPixels * num_channels] + meanValues[0]);
|
||||
data_img[i * num_channels + 1] =
|
||||
static_cast<float>(output_data[(i + nPixels) + n * nPixels * num_channels] + meanValues[1]);
|
||||
data_img[i * num_channels + 2] =
|
||||
static_cast<float>(output_data[(i + 2 * nPixels) + n * nPixels * num_channels] + meanValues[2]);
|
||||
|
||||
float temp = data_img[i * num_channels];
|
||||
data_img[i * num_channels] = data_img[i * num_channels + 2];
|
||||
|
@ -20,11 +20,12 @@ static const char image_message[] = "Path to a folder with images or paths to im
|
||||
static const char model_message[] = "Required. Path to an .xml file with a trained model.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] = "Optional. Specify the target device to infer on (the list of available devices is shown "
|
||||
"below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified";
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify the target device to infer on (the list of available devices is shown "
|
||||
"below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified";
|
||||
|
||||
/// @brief message for plugin custom kernels desc
|
||||
static const char custom_plugin_cfg_message[] = "Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
@ -35,7 +36,8 @@ static const char custom_ex_library_message[] = "Required for CPU plugin custom
|
||||
"Absolute path to a shared library with the kernels implementations.";
|
||||
|
||||
/// @brief message for mean values arguments
|
||||
static const char preprocess_data_message[] = "Mean values. Required if the model needs mean values for preprocessing and postprocessing.";
|
||||
static const char preprocess_data_message[] =
|
||||
"Mean values. Required if the model needs mean values for preprocessing and postprocessing.";
|
||||
|
||||
/// @brief Define flag for showing help message <br>
|
||||
DEFINE_bool(h, false, help_message);
|
||||
|
Loading…
Reference in New Issue
Block a user