Skip to content

Commit

Permalink
Review comments applied
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Jul 2, 2024
1 parent 77de0d4 commit 190835d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ void ConvolutionLayerCPUTest::checkBiasFusing(ov::CompiledModel& execNet) const
bool foundConv = false;
for (const auto& node : execGraph->get_ops()) {
const auto& rtInfo = node->get_rt_info();
auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};

if (getExecValue(ov::exec_model_info::LAYER_TYPE) == "Convolution") {
if (getRuntimeValue(rtInfo, ov::exec_model_info::LAYER_TYPE) == "Convolution") {
foundConv = true;
ASSERT_EQ(3, node->inputs().size());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,8 @@ class GroupConvolutionLayerCPUTest : public testing::WithParamInterface<groupCon
bool foundConv = false;
for (const auto& node : execGraph->get_ops()) {
const auto& rtInfo = node->get_rt_info();
auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};

if (getExecValue(ov::exec_model_info::LAYER_TYPE) == "Convolution") {
if (getRuntimeValue(rtInfo, ov::exec_model_info::LAYER_TYPE) == "Convolution") {
foundConv = true;
ASSERT_EQ(3, node->inputs().size());
break;
Expand Down Expand Up @@ -226,13 +221,8 @@ TEST_P(ExpectFallbackGroupConvolutionLayerCPUTest, CompareWithRefs) {
auto function = compiledModel.get_runtime_model();
for (const auto& node : function->get_ops()) {
const auto& rtInfo = node->get_rt_info();
auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};
if ("Convolution" == getExecValue(ov::exec_model_info::LAYER_TYPE)) {
auto primType = getExecValue(ov::exec_model_info::IMPL_TYPE);
if ("Convolution" == getRuntimeValue(rtInfo, ov::exec_model_info::LAYER_TYPE)) {
auto primType = getRuntimeValue(rtInfo, ov::exec_model_info::IMPL_TYPE);
ASSERT_TRUE(selectedType != primType) << "primType is unexpected: " << primType;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ void FuseTransposeAndReorderTest::check_transpose_count(size_t expectedTranspose
ASSERT_NE(nullptr, runtime_model);
size_t actual_transpose_count = 0;
for (const auto &node : runtime_model->get_ops()) {
const auto & rtInfo = node->get_rt_info();
auto getExecValue = [&rtInfo](const std::string & paramName) -> std::string {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};
if (getExecValue(ov::exec_model_info::LAYER_TYPE) == "Transpose") {
const auto& rtInfo = node->get_rt_info();
if (getRuntimeValue(rtInfo, ov::exec_model_info::LAYER_TYPE) == "Transpose") {
actual_transpose_count++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,9 @@ class MatmulBrgemmInt8Test : public testing::WithParamInterface<MatmulBrgemmInt8
void check_node(std::shared_ptr<const ov::Model> function, const std::string& nodeName) {
ASSERT_NE(nullptr, function);
for (const auto &node : function->get_ops()) {
const auto & rtInfo = node->get_rt_info();
auto getExecValue = [&rtInfo](const std::string & paramName) -> std::string {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};
const auto& rtInfo = node->get_rt_info();
if (node->get_friendly_name() == nodeName) {
auto primType = getExecValue(ov::exec_model_info::IMPL_TYPE);
auto primType = getRuntimeValue(rtInfo, ov::exec_model_info::IMPL_TYPE);
ASSERT_TRUE(primTypeCheck(primType)) << "primType is unexpected: " << primType << " Expected: " << selectedType;
ASSERT_EQ(node->get_output_element_type(0), outType);
ASSERT_EQ(node->get_input_element_type(0), inType);
Expand Down
22 changes: 11 additions & 11 deletions src/plugins/intel_cpu/tests/functional/utils/cpu_test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ov::PrimitivesPriority CPUTestsBase::impls2primProiority(const std::vector<std::
return ov::PrimitivesPriority(str);
}

inline std::string getExecValue(const ov::Node::RTMap& rtInfo, const std::string& paramName) {
std::string getRuntimeValue(const ov::Node::RTMap& rtInfo, const std::string& paramName) {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
Expand All @@ -144,7 +144,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptr<const ov:
ASSERT_NE(nullptr, function);
for (const auto& node : function->get_ops()) {
const auto& rtInfo = node->get_rt_info();
auto getExecValueOutputsLayout = [](const std::shared_ptr<ov::Node>& node) -> std::string {
auto getRuntimeValueOutputsLayout = [](const std::shared_ptr<ov::Node>& node) -> std::string {
auto rtInfo = node->get_rt_info();
auto it = rtInfo.find(ov::exec_model_info::OUTPUT_LAYOUTS);
OPENVINO_ASSERT(rtInfo.end() != it);
Expand All @@ -164,7 +164,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptr<const ov:
return skip_unsquized_1D || permule_of_1;
};

if (nodeType.count(getExecValue(rtInfo, ov::exec_model_info::LAYER_TYPE))) {
if (nodeType.count(getRuntimeValue(rtInfo, ov::exec_model_info::LAYER_TYPE))) {
ASSERT_LE(inFmts.size(), node->get_input_size());
ASSERT_LE(outFmts.size(), node->get_output_size());
for (size_t i = 0; i < inFmts.size(); i++) {
Expand All @@ -173,7 +173,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptr<const ov:
if ((parentPort.get_tensor_ptr() == port.get_tensor_ptr())) {
auto parentNode = parentPort.get_node_shared_ptr();
auto shape = parentNode->get_output_tensor(0).get_partial_shape();
auto actualInputMemoryFormat = getExecValueOutputsLayout(parentNode);
auto actualInputMemoryFormat = getRuntimeValueOutputsLayout(parentNode);

if (!should_be_skipped(shape, inFmts[i])) {
ASSERT_EQ(inFmts[i], cpu_str2fmt(actualInputMemoryFormat.c_str()));
Expand All @@ -193,7 +193,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptr<const ov:
return result;
};

auto actualOutputMemoryFormats = getActualOutputMemoryFormats(getExecValueOutputsLayout(node));
auto actualOutputMemoryFormats = getActualOutputMemoryFormats(getRuntimeValueOutputsLayout(node));

bool isAllEqual = true;
for (size_t i = 1; i < outFmts.size(); i++) {
Expand All @@ -209,15 +209,15 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptr<const ov:
ASSERT_EQ(fmtsNum, actualOutputMemoryFormats.size());
}
for (size_t i = 0; i < fmtsNum; i++) {
const auto actualOutputMemoryFormat = getExecValue(rtInfo, ov::exec_model_info::OUTPUT_LAYOUTS);
const auto actualOutputMemoryFormat = getRuntimeValue(rtInfo, ov::exec_model_info::OUTPUT_LAYOUTS);
const auto shape = node->get_output_partial_shape(i);

if (should_be_skipped(shape, outFmts[i]))
continue;
ASSERT_EQ(outFmts[i], cpu_str2fmt(actualOutputMemoryFormats[i].c_str()));
}

auto primType = getExecValue(rtInfo, ov::exec_model_info::IMPL_TYPE);
auto primType = getRuntimeValue(rtInfo, ov::exec_model_info::IMPL_TYPE);

ASSERT_TRUE(primTypeCheck(primType))
<< "primType is unexpected : " << primType << " Expected : " << selectedType;
Expand Down Expand Up @@ -441,7 +441,7 @@ inline void CheckNumberOfNodesWithTypeImpl(std::shared_ptr<const ov::Model> func
ASSERT_NE(nullptr, function);
size_t actualNodeCount = 0;
for (const auto& node : function->get_ops()) {
if (nodeTypes.count(getExecValue(node->get_rt_info(), ov::exec_model_info::LAYER_TYPE))) {
if (nodeTypes.count(getRuntimeValue(node->get_rt_info(), ov::exec_model_info::LAYER_TYPE))) {
actualNodeCount++;
}
}
Expand Down Expand Up @@ -539,12 +539,12 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,

void CheckNodePrecisionsWithType(const ov::CompiledModel& compiledModel,
const std::string& nodeType,
ov::element::TypeVector&& inPrecisions,
ov::element::TypeVector&& outPrecisions) {
const ov::element::TypeVector& inPrecisions,
const ov::element::TypeVector& outPrecisions) {
const auto function = compiledModel.get_runtime_model();
ASSERT_NE(nullptr, function);
for (const auto& node : function->get_ops()) {
if (getExecValue(node->get_rt_info(), ov::exec_model_info::LAYER_TYPE) == nodeType) {
if (getRuntimeValue(node->get_rt_info(), ov::exec_model_info::LAYER_TYPE) == nodeType) {
ASSERT_EQ(inPrecisions.size(), node->get_input_size());
ASSERT_EQ(outPrecisions.size(), node->get_output_size());
for (size_t i = 0; i < inPrecisions.size(); ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ void CheckNumberOfNodesWithTypes(const ov::CompiledModel& compiledModel,

void CheckNodePrecisionsWithType(const ov::CompiledModel& compiledModel,
const std::string& nodeType,
ov::element::TypeVector&& inPrecisions,
ov::element::TypeVector&& outPrecisions);
const ov::element::TypeVector& inPrecisions,
const ov::element::TypeVector& outPrecisions);

std::string getRuntimeValue(const ov::Node::RTMap& rtInfo, const std::string& paramName);
} // namespace CPUTestUtils
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,10 @@ void CpuTestWithFusing::CheckFusingResults(const std::shared_ptr<const ov::Model
for (const auto & op : function->get_ops()) {
const auto &rtInfo = op->get_rt_info();

auto getExecValue = [](const std::string &paramName, const ov::Node::RTMap& rtInfo) -> std::string {
auto it = rtInfo.find(paramName);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};

auto layerType = getExecValue("layerType", rtInfo);
const auto layerType = CPUTestUtils::getRuntimeValue(rtInfo, ov::exec_model_info::LAYER_TYPE);
if (nodeType.count(layerType)) {
isNodeFound = true;
auto originalLayersNames = getExecValue("originalLayersNames", rtInfo);
auto originalLayersNames = CPUTestUtils::getRuntimeValue(rtInfo, ov::exec_model_info::ORIGINAL_NAMES);
std::string opFriendlyName = op->get_friendly_name();
ASSERT_TRUE(originalLayersNames.find(opFriendlyName) != std::string::npos)
<< "Operation name " << opFriendlyName << " has not been found in originalLayersNames!";
Expand Down

0 comments on commit 190835d

Please sign in to comment.