Skip to content

Commit

Permalink
Sort output info to keep the right order. (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
XinWangIntel authored Apr 16, 2021
1 parent 4ae78c3 commit 2fca665
Showing 1 changed file with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,23 @@ std::vector<std::vector<std::uint8_t>> LayerTestsCommon::CalculateRefs() {
refInputsTypes[i] = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(memory->getTensorDesc().getPrecision());
}

const auto &&outputsInfo = executableNetwork.GetOutputsInfo();
auto mapInfo = executableNetwork.GetOutputsInfo();
std::vector<std::pair<std::string, InferenceEngine::CDataPtr>> outputsInfo(mapInfo.begin(), mapInfo.end());
typedef std::pair<std::string, InferenceEngine::CDataPtr> pp;
struct {
bool operator()(
const pp a,
const pp b) const {
bool result = false;
if (a.first.length() < b.first.length()) {
result = true;
} else if (a.first.compare(b.first) < 0) {
result = true;
}
return result;
}
} reverseNameLess;
std::sort(outputsInfo.begin(), outputsInfo.end(), reverseNameLess);
std::vector<ngraph::element::Type_t> convertType;
convertType.reserve(outputsInfo.size());
for (const auto &output : outputsInfo) {
Expand Down Expand Up @@ -407,7 +423,24 @@ std::vector<std::vector<std::uint8_t>> LayerTestsCommon::CalculateRefs() {

std::vector<InferenceEngine::Blob::Ptr> LayerTestsCommon::GetOutputs() {
auto outputs = std::vector<InferenceEngine::Blob::Ptr>{};
for (const auto &output : executableNetwork.GetOutputsInfo()) {
auto mapInfo = executableNetwork.GetOutputsInfo();
std::vector<std::pair<std::string, InferenceEngine::CDataPtr>> outputsInfo(mapInfo.begin(), mapInfo.end());
typedef std::pair<std::string, InferenceEngine::CDataPtr> pp;
struct {
bool operator()(
const pp a,
const pp b) const {
bool result = false;
if (a.first.length() < b.first.length()) {
result = true;
} else if (a.first.compare(b.first) < 0) {
result = true;
}
return result;
}
} reverseNameLess;
std::sort(outputsInfo.begin(), outputsInfo.end(), reverseNameLess);
for (const auto &output : outputsInfo) {
const auto &name = output.first;
outputs.push_back(inferRequest.GetBlob(name));
}
Expand Down

0 comments on commit 2fca665

Please sign in to comment.