Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace interpreterFunction with interpret_model #870

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions modules/nvidia_plugin/tests/unit/cuda_multi_graph_ti_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "ops/result.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/utils/data_utils.hpp"
#include "openvino/opsets/opset1.hpp"
#include "common_test_utils/test_helpers.hpp"

using namespace ov::nvidia_gpu;
using namespace testing;
Expand Down Expand Up @@ -44,34 +46,21 @@ void generateInput(ov::Tensor& tensor, int to = TO, int from = FROM, int seed =
std::vector<std::vector<CalcType>> calcRefs(std::shared_ptr<ov::Model> model,
const std::vector<std::shared_ptr<ov::Tensor>>& inputs) {
auto refModel = model->clone();
auto refModelInputs = refModel->inputs();
ASSERT_EQ(refModelInputs.size(), inputs.size());

auto referenceInputs = std::vector<std::vector<uint8_t>>(inputs.size());
auto refInputsTypes = std::vector<ov::element::Type>(inputs.size());
for (std::size_t i = 0; i < inputs.size(); ++i) {
const auto& input = inputs[i];
const auto inputSize = input->get_byte_size();

auto& referenceInput = referenceInputs[i];
referenceInput.resize(inputSize);

const auto* buffer = static_cast<const uint8_t*>(input->data());
std::copy(buffer, buffer + inputSize, referenceInput.data());

refInputsTypes[i] = CALC_ELEMENT_TYPE;
std::map<std::shared_ptr<ov::Node>, ov::Tensor> referenceInputs;
for (size_t i = 0; i < refModelInputs.size(); ++i) {
referenceInputs[refModelInputs[i]] = inputs[i];
}

const auto expectedOutputs = ngraph::helpers::interpreterFunction(refModel, referenceInputs, refInputsTypes);
const auto expectedOutputs = ov::test::utils::interpret_model(refModel, referenceInputs);

std::vector<std::vector<CalcType>> res(expectedOutputs.size());
for (std::size_t i = 0; i < expectedOutputs.size(); ++i) {
EXPECT_EQ(expectedOutputs[i].first, CALC_ELEMENT_TYPE);
const auto& expOut = expectedOutputs[i].second;
auto& resOut = res[i];
const auto resOutSize = expOut.size() / sizeof(CalcType);
resOut.resize(resOutSize);

const auto* buffer = static_cast<const CalcType*>(static_cast<const void*>(expOut.data()));
std::copy(buffer, buffer + resOutSize, resOut.data());
for (size_t i = 0; i < expectedOutputs.size(); ++i) {
EXPECT_EQ(expectedOutputs[i].get_element_type(), CALC_ELEMENT_TYPE);
res[i].resize(expectedOutputs[i].get_size());
std::memcpy(res[i].data(), expectedOutputs[i].data(), expectedOutputs[i].get_byte_size());
}
return res;
}
Expand Down