[Time tests] Update reshape pipeline (use default inputs before reshape for data generation) (#10129)
This commit is contained in:
parent
14fcd196a3
commit
857c0bd9dd
@ -138,6 +138,20 @@ ov::Shape getTensorStaticShape(ov::Output<const ov::Node> &input,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return copy of inputs object before reshape
|
||||
*/
|
||||
std::vector<ov::Output<ov::Node>> getCopyOfDefaultInputs(std::vector<ov::Output<ov::Node>> defaultInputs) {
|
||||
std::vector<ov::Output<ov::Node>> inputsCopy;
|
||||
for (size_t i = 0; i < defaultInputs.size(); i++) {
|
||||
auto nodeCopy = defaultInputs[i].get_node()->clone_with_new_inputs({});
|
||||
auto inputNode = ov::Output<ov::Node>(nodeCopy);
|
||||
inputsCopy.push_back(inputNode);
|
||||
}
|
||||
return inputsCopy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Fill infer_request tensors with random values. The model shape is set separately. (OV API 2)
|
||||
*/
|
||||
|
@ -44,6 +44,12 @@ std::map<std::string, ov::PartialShape> parseReshapeShapes(const std::string &sh
|
||||
std::map<std::string, std::vector<size_t>> parseDataShapes(const std::string &shapeString);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return copy of inputs object before reshape
|
||||
*/
|
||||
std::vector<ov::Output<ov::Node>> getCopyOfDefaultInputs(std::vector<ov::Output<ov::Node>> defaultInputs);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Getting tensor shapes. If tensor is dynamic, static shape from data info will be returned.
|
||||
*/
|
||||
|
@ -27,6 +27,8 @@ int runPipeline(const std::string &model, const std::string &device, const bool
|
||||
ov::CompiledModel exeNetwork;
|
||||
ov::InferRequest inferRequest;
|
||||
|
||||
std::vector<ov::Output<ov::Node>> default_inputs;
|
||||
|
||||
bool reshape = false;
|
||||
if (!reshapeShapes.empty()) {
|
||||
reshape = true;
|
||||
@ -59,6 +61,7 @@ int runPipeline(const std::string &model, const std::string &device, const bool
|
||||
if (reshape) {
|
||||
{
|
||||
SCOPED_TIMER(reshape);
|
||||
default_inputs = getCopyOfDefaultInputs(cnnNetwork->inputs());
|
||||
cnnNetwork->reshape(reshapeShapes);
|
||||
}
|
||||
}
|
||||
@ -80,8 +83,10 @@ int runPipeline(const std::string &model, const std::string &device, const bool
|
||||
{
|
||||
SCOPED_TIMER(fill_inputs);
|
||||
std::vector<ov::Output<const ov::Node>> inputs = exeNetwork.inputs();
|
||||
if (reshape) {
|
||||
fillTensorsWithSpecifiedShape(inferRequest, inputs,dataShapes);
|
||||
if (reshape && dataShapes.empty()) {
|
||||
fillTensors(inferRequest, default_inputs);
|
||||
} else if (reshape && !dataShapes.empty()) {
|
||||
fillTensorsWithSpecifiedShape(inferRequest, inputs, dataShapes);
|
||||
} else {
|
||||
fillTensors(inferRequest, inputs);
|
||||
}
|
||||
|
@ -36,10 +36,6 @@ bool parseAndCheckCommandLine(int argc, char **argv) {
|
||||
throw std::logic_error(
|
||||
"Statistics file path is required but not set. Please set -s option.");
|
||||
|
||||
if (!FLAGS_reshape_shapes.empty() && FLAGS_data_shapes.empty())
|
||||
throw std::logic_error(
|
||||
"Data shapes is required for reshape shapes argument. Please set -data_shapes option.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user