OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Fix string literal conditions used in OPENVINO_ASSERT (#33911)
Arseniy Obolenskiya070c440c7b3
diff --git a/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp b/src/common/low_precision_transformations/include/low_precision/layer_transformation.hppindex 6ee711e25e1..788e61e11c8 100644--- a/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp+++ b/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp@@ -131,7 +131,7 @@ public:default:OPENVINO_ASSERT(false, "unexpected precision ", precision);}- OPENVINO_ASSERT(false, "unexpected levels ", levels, " for precision ", precision);+ OPENVINO_THROW("unexpected levels ", levels, " for precision ", precision);}static float getMaxValue(const element::Type precision, const size_t levels) {diff --git a/src/plugins/hetero/src/remote_context.cpp b/src/plugins/hetero/src/remote_context.cppindex 80fbab3a2eb..4dc5d6b8d5e 100644--- a/src/plugins/hetero/src/remote_context.cpp+++ b/src/plugins/hetero/src/remote_context.cpp@@ -14,10 +14,9 @@ namespace hetero {RemoteContext::RemoteContext(std::map<std::string, ov::SoPtr<ov::IRemoteContext>> contexts): m_contexts(std::move(contexts)) {- if (m_contexts.empty()) {- OPENVINO_ASSERT("HETERO RemoteContext must have at least one underlying context");- }+ OPENVINO_ASSERT(!m_contexts.empty(), "HETERO RemoteContext must have at least one underlying context");}+const ov::AnyMap& RemoteContext::get_property() const {return m_contexts.begin()->second->get_property();}diff --git a/src/plugins/intel_cpu/src/nodes/region_yolo.cpp b/src/plugins/intel_cpu/src/nodes/region_yolo.cppindex b543e110d1d..3248efebd8c 100644--- a/src/plugins/intel_cpu/src/nodes/region_yolo.cpp+++ b/src/plugins/intel_cpu/src/nodes/region_yolo.cpp@@ -417,7 +417,7 @@ inline void RegionYolo::calculate_logistic(size_t start_index, int count, uint8_bf16_dst_data[i + start_index] = logistic_scalar(bf16_dst_data[i + start_index]);}} else {- CPU_NODE_ASSERT("Unsupported precision configuration outPrc=", output_prec.get_type_name());+ CPU_NODE_THROW("Unsupported precision configuration outPrc=", output_prec.get_type_name());}}}diff --git a/src/plugins/intel_gpu/src/graph/common_utils/jitter.cpp b/src/plugins/intel_gpu/src/graph/common_utils/jitter.cppindex 547cd64907e..91e6a34174f 100644--- a/src/plugins/intel_gpu/src/graph/common_utils/jitter.cpp+++ b/src/plugins/intel_gpu/src/graph/common_utils/jitter.cpp@@ -15,6 +15,8 @@ namespace {std::vector<ChannelName> get_data_channels_order(size_t rank) {using channel = ChannelName;switch (rank) {+ case 0:+ return {};case 1:return {channel::BATCH};case 2:@@ -32,7 +34,7 @@ std::vector<ChannelName> get_data_channels_order(size_t rank) {case 8:return {channel::BATCH, channel::FEATURE, channel::V, channel::U, channel::W, channel::Z, channel::Y, channel::X};default:- OPENVINO_ASSERT("[GPU] Unexpected rank ", rank, " in get_data_channels_order() func");+ OPENVINO_THROW("[GPU] Unexpected rank ", rank, " in get_data_channels_order() func");}return {};diff --git a/src/plugins/intel_gpu/src/graph/reshape.cpp b/src/plugins/intel_gpu/src/graph/reshape.cppindex f49910f7284..4310ec4700c 100644--- a/src/plugins/intel_gpu/src/graph/reshape.cpp+++ b/src/plugins/intel_gpu/src/graph/reshape.cpp@@ -113,12 +113,9 @@ layout reshape_inst::calc_output_layout(reshape_node const& node, kernel_impl_paauto input_layout = impl_param.get_non_padded_input_layout();auto desc = impl_param.typed_desc<reshape>();if (desc->output_shape.count() == 0) {- if (desc->output_partial_shape.size() != 0) {- format out_fmt = format::adjust_to_rank(input_layout.format, desc->output_partial_shape.rank().get_length());- return layout{desc->output_partial_shape, input_layout.data_type, out_fmt};- } else {- OPENVINO_ASSERT("[GPU] Output shape is not provided");- }+ OPENVINO_ASSERT(desc->output_partial_shape.size() != 0, "[GPU] Output shape is not provided");+ format out_fmt = format::adjust_to_rank(input_layout.format, desc->output_partial_shape.rank().get_length());+ return layout{desc->output_partial_shape, input_layout.data_type, out_fmt};}auto sizes = desc->output_shape.sizes();diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cppindex 1de4baed581..83c568b0636 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cpp@@ -162,7 +162,7 @@ JitConstants FullyConnected_GEMV::GetJitConstants(const fully_connected_params&} else if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2) {jit.AddConstant(MakeJitConstant("FILTER_LAYOUT_OS_IS_YX_TYPE", 2));} else {- OPENVINO_ASSERT("GEMV doesn't support this weights layout: ", params.weights.GetLayout());+ OPENVINO_THROW("GEMV doesn't support this weights layout: ", params.weights.GetLayout());}if (params.weights.GetDType() == WeightsType::UINT4) {@@ -170,7 +170,7 @@ JitConstants FullyConnected_GEMV::GetJitConstants(const fully_connected_params&} else if (params.weights.GetDType() == WeightsType::INT4) {jit.AddConstant(MakeJitConstant("WEI_UINT4", 0));} else {- OPENVINO_ASSERT("GEMV only support INT4 and UINT4, doesn't support ", static_cast<size_t>(params.weights.GetDType()));+ OPENVINO_THROW("GEMV only support INT4 and UINT4, doesn't support ", static_cast<size_t>(params.weights.GetDType()));}jit.AddConstant(MakeJitConstant("SIMD", simd));diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cppindex 33ef33ec511..1453e45b5b2 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp@@ -256,7 +256,7 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swiov::as_type_ptr<ov::op::v0::Constant>(zp_convert->get_input_node_shared_ptr(0));cur_zp_val = zp_const->cast_vector<int32_t>()[0];} else {- OPENVINO_ASSERT("Unsupported zp input node for FC horizontal fusion");+ OPENVINO_THROW("Unsupported zp input node for FC horizontal fusion");}if (cur_zp_val != scalar_zp_val)return false;diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cppindex add7956fa48..ec154a3ffdd 100644--- a/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cpp@@ -1,5 +1,7 @@// Copyright (C) 2018-2026 Intel Corporation// SPDX-License-Identifier: Apache-2.0+//+#include <iostream>#include <numeric>#include "test_utils.h"@@ -139,7 +141,7 @@ void get_reference(const std::vector<ov::float16>& input,acc += fa0 * input_r[2 * ki];acc += fa1 * input_r[2 * ki + 1];} else {- OPENVINO_ASSERT("Not implemented dt");+ OPENVINO_THROW("Not implemented dt");}}scale_group++;