Fixes according to new api
This commit is contained in:
parent
9ff7886d23
commit
fd171ee275
@ -47,7 +47,7 @@ protected:
|
|||||||
Config configuration;
|
Config configuration;
|
||||||
|
|
||||||
std::shared_ptr<ov::Function> function, functionRefs = nullptr;
|
std::shared_ptr<ov::Function> function, functionRefs = nullptr;
|
||||||
std::map<std::string, ov::runtime::Tensor> inputs;
|
std::map<std::shared_ptr<ov::Node>, ov::runtime::Tensor> inputs;
|
||||||
std::vector<ngraph::PartialShape> inputDynamicShapes;
|
std::vector<ngraph::PartialShape> inputDynamicShapes;
|
||||||
std::vector<std::vector<ngraph::Shape>> targetStaticShapes;
|
std::vector<std::vector<ngraph::Shape>> targetStaticShapes;
|
||||||
ElementType inType = ov::element::undefined, outType = ov::element::undefined;
|
ElementType inType = ov::element::undefined, outType = ov::element::undefined;
|
||||||
|
@ -155,11 +155,11 @@ void SubgraphBaseTest::compile_model() {
|
|||||||
|
|
||||||
void SubgraphBaseTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
|
void SubgraphBaseTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
|
||||||
inputs.clear();
|
inputs.clear();
|
||||||
const auto& params = function->inputs();
|
const auto& funcInputs = function->inputs();
|
||||||
for (int i = 0; i < params.size(); ++i) {
|
for (int i = 0; i < funcInputs.size(); ++i) {
|
||||||
const auto& param = params[i];
|
const auto& funcInput = funcInputs[i];
|
||||||
ov::runtime::Tensor tensor = ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i]);
|
ov::runtime::Tensor tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]);
|
||||||
inputs.insert({param.get_any_name(), tensor});
|
inputs.insert({funcInput.get_node_shared_ptr(), tensor});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ std::vector<ov::runtime::Tensor> SubgraphBaseTest::calculate_refs() {
|
|||||||
std::vector<ov::runtime::Tensor> SubgraphBaseTest::get_plugin_outputs() {
|
std::vector<ov::runtime::Tensor> SubgraphBaseTest::get_plugin_outputs() {
|
||||||
auto outputs = std::vector<ov::runtime::Tensor>{};
|
auto outputs = std::vector<ov::runtime::Tensor>{};
|
||||||
for (const auto& output : function->outputs()) {
|
for (const auto& output : function->outputs()) {
|
||||||
outputs.push_back(inferRequest.get_tensor(output.get_any_name()));
|
outputs.push_back(inferRequest.get_tensor(output));
|
||||||
}
|
}
|
||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
@ -44,32 +44,32 @@ std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo<Eltwi
|
|||||||
void EltwiseLayerTest::generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) {
|
void EltwiseLayerTest::generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) {
|
||||||
inputs.clear();
|
inputs.clear();
|
||||||
const auto opType = std::get<1>(GetParam());
|
const auto opType = std::get<1>(GetParam());
|
||||||
const auto& params = function->inputs();
|
const auto& funcInputs = function->inputs();
|
||||||
for (int i = 0; i < params.size(); ++i) {
|
for (int i = 0; i < funcInputs.size(); ++i) {
|
||||||
const auto& param = params[i];
|
const auto& funcInput = funcInputs[i];
|
||||||
ov::runtime::Tensor tensor;
|
ov::runtime::Tensor tensor;
|
||||||
bool isReal = param.get_element_type().is_real();
|
bool isReal = funcInput.get_element_type().is_real();
|
||||||
switch (opType) {
|
switch (opType) {
|
||||||
case ngraph::helpers::EltwiseTypes::POWER:
|
case ngraph::helpers::EltwiseTypes::POWER:
|
||||||
case ngraph::helpers::EltwiseTypes::MOD:
|
case ngraph::helpers::EltwiseTypes::MOD:
|
||||||
case ngraph::helpers::EltwiseTypes::FLOOR_MOD:
|
case ngraph::helpers::EltwiseTypes::FLOOR_MOD:
|
||||||
tensor = isReal ?
|
tensor = isReal ?
|
||||||
ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i], 2, 2, 128) :
|
ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 2, 2, 128) :
|
||||||
ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i], 4, 2);
|
ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 4, 2);
|
||||||
break;
|
break;
|
||||||
case ngraph::helpers::EltwiseTypes::DIVIDE:
|
case ngraph::helpers::EltwiseTypes::DIVIDE:
|
||||||
tensor = isReal ?
|
tensor = isReal ?
|
||||||
ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i], 2, 2, 128) :
|
ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 2, 2, 128) :
|
||||||
ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i], 100, 101);
|
ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 100, 101);
|
||||||
break;
|
break;
|
||||||
case ngraph::helpers::EltwiseTypes::ERF:
|
case ngraph::helpers::EltwiseTypes::ERF:
|
||||||
tensor = ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i], 6, -3);
|
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 6, -3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tensor = ov::test::utils::create_and_fill_tensor(param.get_element_type(), targetInputStaticShapes[i]);
|
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
inputs.insert({param.get_any_name(), tensor});
|
inputs.insert({funcInput.get_node_shared_ptr(), tensor});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ std::vector<std::pair<ngraph::element::Type, std::vector<std::uint8_t>>>
|
|||||||
|
|
||||||
std::vector<ov::runtime::Tensor>
|
std::vector<ov::runtime::Tensor>
|
||||||
interpretFunction(const std::shared_ptr<Function> &function,
|
interpretFunction(const std::shared_ptr<Function> &function,
|
||||||
const std::map<std::string, ov::runtime::Tensor>& inputs);
|
const std::map<std::shared_ptr<ov::Node>, ov::runtime::Tensor>& inputs);
|
||||||
|
|
||||||
//
|
//
|
||||||
// This function compares two nGraph functions and requires them to have exactly one output
|
// This function compares two nGraph functions and requires them to have exactly one output
|
||||||
|
@ -145,38 +145,41 @@ std::vector<std::pair<ngraph::element::Type, std::vector<std::uint8_t>>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ov::runtime::Tensor> interpretFunction(const std::shared_ptr<Function> &function,
|
std::vector<ov::runtime::Tensor> interpretFunction(const std::shared_ptr<Function> &function,
|
||||||
const std::map<std::string, ov::runtime::Tensor>& inputs) {
|
const std::map<std::shared_ptr<ov::Node>, ov::runtime::Tensor>& inputs) {
|
||||||
runtime::Backend::set_backend_shared_library_search_directory("");
|
runtime::Backend::set_backend_shared_library_search_directory("");
|
||||||
auto backend = runtime::Backend::create("INTERPRETER");
|
auto backend = runtime::Backend::create("INTERPRETER");
|
||||||
|
|
||||||
const auto ¶meters = function->inputs();
|
const auto &funcInputs = function->inputs();
|
||||||
const auto ¶metersNumber = parameters.size();
|
const auto &funcInputsNumber = funcInputs.size();
|
||||||
const auto &inputsNumber = inputs.size();
|
const auto &inputsNumber = inputs.size();
|
||||||
NGRAPH_CHECK(parametersNumber == inputsNumber,
|
NGRAPH_CHECK(funcInputsNumber == inputsNumber,
|
||||||
"Got function (", function->get_friendly_name(), ") with ", parametersNumber, " parameters, but ",
|
"Got function (", function->get_friendly_name(), ") with ", funcInputsNumber, " parameters, but ",
|
||||||
inputsNumber, " input blobs");
|
inputsNumber, " input blobs");
|
||||||
|
|
||||||
auto inputTensors = std::vector<std::shared_ptr<runtime::Tensor>>{};
|
auto inputTensors = std::vector<std::shared_ptr<runtime::Tensor>>{};
|
||||||
for (size_t i = 0; i < parametersNumber; ++i) {
|
for (size_t i = 0; i < funcInputsNumber; ++i) {
|
||||||
const auto ¶meter = parameters[i];
|
const auto &input = funcInputs[i];
|
||||||
const auto ¶meterShape = parameter.get_shape();
|
const auto &inputShape = input.get_shape();
|
||||||
const auto ¶meterType = parameter.get_element_type();
|
const auto &inputType = input.get_element_type();
|
||||||
const auto ¶meterSize = shape_size(parameterShape) * parameterType.size();
|
const auto &inputSize = shape_size(inputShape) * inputType.size();
|
||||||
|
|
||||||
auto inputIt = inputs.find(parameter.get_any_name());
|
auto inputIt = std::find_if(inputs.begin(), inputs.end(),
|
||||||
|
[&input](std::pair<std::shared_ptr<ov::Node>, ov::runtime::Tensor> elem) {
|
||||||
|
return elem.first->get_friendly_name() == input.get_node_shared_ptr()->get_friendly_name();
|
||||||
|
});
|
||||||
if (inputIt == inputs.end()) {
|
if (inputIt == inputs.end()) {
|
||||||
throw std::runtime_error("Parameter: " + parameter.get_any_name()+ " was not find in input parameters");
|
throw std::runtime_error("Parameter: " + input.get_node_shared_ptr()->get_friendly_name() + " was not find in input parameters");
|
||||||
}
|
}
|
||||||
auto input = inputIt->second;
|
auto inputTensor = inputIt->second;
|
||||||
|
|
||||||
const auto &inputSize = input.get_byte_size();
|
const auto &inputTensorSize = inputTensor.get_byte_size();
|
||||||
NGRAPH_CHECK(parameterSize == inputSize,
|
NGRAPH_CHECK(inputSize == inputTensorSize,
|
||||||
"Got parameter (", parameter.get_any_name(), ") of size ", parameterSize,
|
"Got parameter (", input.get_node_shared_ptr()->get_friendly_name(), ") of size ", inputSize,
|
||||||
" bytes, but corresponding input ",
|
" bytes, but corresponding input ",
|
||||||
" has ", inputSize, " bytes");
|
" has ", inputTensorSize, " bytes");
|
||||||
|
|
||||||
auto tensor = backend->create_tensor(parameterType, parameterShape);
|
auto tensor = backend->create_tensor(inputType, inputShape);
|
||||||
tensor->write(input.data(), parameterSize);
|
tensor->write(inputTensor.data(), inputSize);
|
||||||
inputTensors.push_back(tensor);
|
inputTensors.push_back(tensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,14 +905,14 @@ std::ostream& operator<<(std::ostream & os, MemoryTransformation type) {
|
|||||||
|
|
||||||
void resize_function(std::shared_ptr<ov::Function> function,
|
void resize_function(std::shared_ptr<ov::Function> function,
|
||||||
const std::vector<ov::Shape>& targetInputStaticShapes) {
|
const std::vector<ov::Shape>& targetInputStaticShapes) {
|
||||||
auto params = function->get_parameters();
|
auto inputs = function->inputs();
|
||||||
std::map<std::string, ov::PartialShape> shapes;
|
std::map<ov::Output<ov::Node>, ov::PartialShape> shapes;
|
||||||
if (params.size() > targetInputStaticShapes.size()) {
|
if (inputs.size() > targetInputStaticShapes.size()) {
|
||||||
throw std::runtime_error("targetInputStaticShapes.size() = " + std::to_string(targetInputStaticShapes.size()) + " != params.size() = "
|
throw std::runtime_error("targetInputStaticShapes.size() = " + std::to_string(targetInputStaticShapes.size()) + " != inputs.size() = "
|
||||||
+ std::to_string(params.size()));
|
+ std::to_string(inputs.size()));
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < params.size(); i++) {
|
for (size_t i = 0; i < inputs.size(); i++) {
|
||||||
shapes.insert({params[i]->get_output_tensor(0).get_any_name(), targetInputStaticShapes[i]});
|
shapes.insert({inputs[i], targetInputStaticShapes[i]});
|
||||||
}
|
}
|
||||||
function->reshape(shapes);
|
function->reshape(shapes);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user