From 21601398d67fe8edbc8c19d881a65236528d1aed Mon Sep 17 00:00:00 2001 From: Victor Kuznetsov Date: Wed, 9 Feb 2022 14:15:16 +0300 Subject: [PATCH] Remove dynamism from time_tests (API 1.0) (#10193) --- tests/lib/src/reshape_utils.cpp | 20 --------- tests/lib/src/reshape_utils.h | 44 ++++++++----------- .../src/timetests/timetest_infer.cpp | 19 +------- .../src/timetests/timetest_infer_api_2.cpp | 6 +-- 4 files changed, 22 insertions(+), 67 deletions(-) diff --git a/tests/lib/src/reshape_utils.cpp b/tests/lib/src/reshape_utils.cpp index 51e66dce5ee..3c7e56b5003 100644 --- a/tests/lib/src/reshape_utils.cpp +++ b/tests/lib/src/reshape_utils.cpp @@ -90,26 +90,6 @@ std::vector split(const std::string &s, char delim) { } -/** - * @brief Reshape blobs with dynamic shapes with static information from data shape - */ -void setBlobsStaticShapes(InferenceEngine::InferRequest inferRequest, - const InferenceEngine::ConstInputsDataMap &inputsInfo, - std::map> dataShape) { - for (const InferenceEngine::ConstInputsDataMap::value_type &item : inputsInfo) { - InferenceEngine::Blob::Ptr inputBlob = inferRequest.GetBlob(item.first); - - if (dataShape.count(item.first)) { - InferenceEngine::SizeVector newInputShape; - for (size_t i = 0; i < dataShape[item.first].size(); i++) { - newInputShape.emplace_back(dataShape[item.first][i]); - } - inputBlob->setShape(newInputShape); - } - } -} - - /** * @brief Getting tensor shapes. If tensor is dynamic, static shape from data info will be returned. */ diff --git a/tests/lib/src/reshape_utils.h b/tests/lib/src/reshape_utils.h index 1bd3b2323a3..97b9b63864f 100644 --- a/tests/lib/src/reshape_utils.h +++ b/tests/lib/src/reshape_utils.h @@ -8,23 +8,6 @@ #include -/** - * @brief Fill InferenceEngine tensor with random values. The model shape is set separately. - */ -template -ov::Tensor fillTensorRandomDynamic(ov::Output &input, ov::Shape shape) { - ov::Tensor tensor {input.get_element_type(), shape}; - std::vectorvalues(ov::shape_size(shape)); - - for (size_t i = 0; i < values.size(); ++i) { - values[i] = 1 + static_cast(rand()) / (static_cast(RAND_MAX / (std::numeric_limits::max() - 1))); - } - std::memcpy(tensor.data(), values.data(), sizeof(T) * values.size()); - - return tensor; -} - - /** * @brief Split input string using specified delimiter. Return vector with input tensor information @@ -57,16 +40,25 @@ ov::Shape getTensorStaticShape(ov::Output &input, std::map> dataShape); -/** - * @brief Reshape blobs with dynamic shapes with static information from data shape - */ -void setBlobsStaticShapes(InferenceEngine::InferRequest inferRequest, - const InferenceEngine::ConstInputsDataMap &inputsInfo, - std::map> dataShape); - - /** * @brief Fill infer_request tensors with random values. The model shape is set separately. (OV API 2) */ void fillTensorsWithSpecifiedShape(ov::InferRequest& infer_request, std::vector> &inputs, - std::map> dataShape); \ No newline at end of file + std::map> dataShape); + + +/** + * @brief Fill InferenceEngine tensor with random values. The model shape is set separately. + */ +template +ov::Tensor fillTensorRandomDynamic(ov::Output &input, ov::Shape shape) { + ov::Tensor tensor {input.get_element_type(), shape}; + std::vectorvalues(ov::shape_size(shape)); + + for (size_t i = 0; i < values.size(); ++i) { + values[i] = 1 + static_cast(rand()) / (static_cast(RAND_MAX / (std::numeric_limits::max() - 1))); + } + std::memcpy(tensor.data(), values.data(), sizeof(T) * values.size()); + + return tensor; +} \ No newline at end of file diff --git a/tests/time_tests/src/timetests/timetest_infer.cpp b/tests/time_tests/src/timetests/timetest_infer.cpp index beedd034129..136fcd413aa 100644 --- a/tests/time_tests/src/timetests/timetest_infer.cpp +++ b/tests/time_tests/src/timetests/timetest_infer.cpp @@ -5,7 +5,6 @@ #include #include "common_utils.h" -#include "reshape_utils.h" #include "timetests_helper/timer.h" #include "timetests_helper/utils.h" @@ -27,11 +26,6 @@ int runPipeline(const std::string &model, const std::string &device, const bool InferenceEngine::InferRequest inferRequest; size_t batchSize = 0; - bool reshape = false; - if (!reshapeShapes.empty()) { - reshape = true; - } - // first_inference_latency = time_to_inference + first_inference { SCOPED_TIMER(time_to_inference); @@ -56,12 +50,6 @@ int runPipeline(const std::string &model, const std::string &device, const bool cnnNetwork = ie.ReadNetwork(model); batchSize = cnnNetwork.getBatchSize(); } - if (reshape) { - { - SCOPED_TIMER(reshape); - cnnNetwork.reshape(reshapeShapes); - } - } { SCOPED_TIMER(load_network); exeNetwork = ie.LoadNetwork(cnnNetwork, device); @@ -81,12 +69,7 @@ int runPipeline(const std::string &model, const std::string &device, const bool SCOPED_TIMER(fill_inputs); const InferenceEngine::ConstInputsDataMap inputsInfo(exeNetwork.GetInputsInfo()); batchSize = batchSize != 0 ? batchSize : 1; - if (reshape) { - setBlobsStaticShapes(inferRequest, inputsInfo, dataShapes); - fillBlobs(inferRequest, inputsInfo, batchSize); - } else { - fillBlobs(inferRequest, inputsInfo, batchSize); - } + fillBlobs(inferRequest, inputsInfo, batchSize); } inferRequest.Infer(); } diff --git a/tests/time_tests/src/timetests/timetest_infer_api_2.cpp b/tests/time_tests/src/timetests/timetest_infer_api_2.cpp index c92f7a0e4d9..b4ea6a45f83 100644 --- a/tests/time_tests/src/timetests/timetest_infer_api_2.cpp +++ b/tests/time_tests/src/timetests/timetest_infer_api_2.cpp @@ -27,7 +27,7 @@ int runPipeline(const std::string &model, const std::string &device, const bool ov::CompiledModel exeNetwork; ov::InferRequest inferRequest; - std::vector> default_inputs; + std::vector> defaultInputs; bool reshape = false; if (!reshapeShapes.empty()) { @@ -61,7 +61,7 @@ int runPipeline(const std::string &model, const std::string &device, const bool if (reshape) { { SCOPED_TIMER(reshape); - default_inputs = getCopyOfDefaultInputs(cnnNetwork->inputs()); + defaultInputs = getCopyOfDefaultInputs(cnnNetwork->inputs()); cnnNetwork->reshape(reshapeShapes); } } @@ -84,7 +84,7 @@ int runPipeline(const std::string &model, const std::string &device, const bool SCOPED_TIMER(fill_inputs); std::vector> inputs = exeNetwork.inputs(); if (reshape && dataShapes.empty()) { - fillTensors(inferRequest, default_inputs); + fillTensors(inferRequest, defaultInputs); } else if (reshape && !dataShapes.empty()) { fillTensorsWithSpecifiedShape(inferRequest, inputs, dataShapes); } else {