Skip to content

Commit fddda65

Browse files
vurusovssshlyapn
andauthored
Fix use of OPENVINO_ASSERT (openvinotoolkit#23023)
### Details: - `OPENVINO_ASSERT` takes boolean expression as first argument. In order to explicitly throw AssertFailure, need to specify `false`, non-empty string will be treated as `true` --------- Co-authored-by: Sergey Shlyapnikov <sergey.shlyapnikov@intel.com>
1 parent 45ce9e7 commit fddda65

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

src/bindings/python/src/pyopenvino/utils/utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ ov::Any py_object_to_any(const py::object& py_obj) {
324324
detected_type = type;
325325
return;
326326
}
327-
OPENVINO_ASSERT("Incorrect attribute. Mixed types in the list are not allowed.");
327+
OPENVINO_THROW("Incorrect attribute. Mixed types in the list are not allowed.");
328328
};
329329
if (py::isinstance<py::str>(it)) {
330330
check_type(PY_TYPE::STR);

src/plugins/intel_gpu/src/graph/primitive_inst.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ event::ptr primitive_inst::execute(const std::vector<event::ptr>& events) {
13741374
auto ev = get_network().get_primitive_event(id);
13751375
dependencies.emplace_back(ev);
13761376
} catch (const std::out_of_range& oor) {
1377-
OPENVINO_ASSERT(false, "[GPU] execution order corrupted: ", oor.what());
1377+
OPENVINO_THROW("[GPU] execution order corrupted: ", oor.what());
13781378
}
13791379
}
13801380
}
@@ -2020,7 +2020,10 @@ bool primitive_inst::is_valid_fusion() const {
20202020
if (fd.is_type<eltwise>() || fd.is_type<activation>()) {
20212021
fused_eltwise_prims.push_back(fd);
20222022
} else {
2023-
OPENVINO_ASSERT("[GPU] Unsupported fused operation in dynamic shape : ", fd.desc->id);
2023+
if (fd.is_type<reorder>())
2024+
continue;
2025+
2026+
OPENVINO_THROW("[GPU] Unsupported fused operation in dynamic shape: type=", fd.desc->type_string(), ", id=", fd.desc->id);
20242027
}
20252028
}
20262029

src/plugins/intel_gpu/src/graph/reshape.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ layout reshape_inst::calc_output_layout(reshape_node const& node, kernel_impl_pa
2424
if (desc->output_partial_shape.size() != 0) {
2525
return layout{desc->output_partial_shape, input_layout.data_type, input_layout.format};
2626
} else {
27-
OPENVINO_ASSERT("[GPU] Output shape is not provided");
27+
OPENVINO_THROW("[GPU] Output shape is not provided");
2828
}
2929
}
3030

@@ -110,7 +110,7 @@ std::vector<layout> reshape_inst::calc_output_layouts(reshape_node const& node,
110110
break;
111111
}
112112
default:
113-
OPENVINO_ASSERT("Unsupported reshape mode");
113+
OPENVINO_THROW("Unsupported reshape mode");
114114
}
115115
};
116116

src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_blocked_opt.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ JitConstants EltwiseKernel_blocked_opt::MakeLoadJitConstants(const eltwise_param
189189
else if (DataTensor::ChannelsCount(params.inputs[input_idx].GetLayout()) == 5)
190190
default_indexing_str = "b, (f_block * " + toCodeString(vec_size) +"), z, y, x";
191191
else
192-
OPENVINO_ASSERT("MakeLoadJit : Unexpected dimension for eltwise optimized kernel.");
192+
OPENVINO_THROW("MakeLoadJit : Unexpected dimension for eltwise optimized kernel.");
193193

194194
// Generate Jit
195195
switch (input.mode) {
@@ -439,7 +439,7 @@ static inline int GetInnerBatchBlockSize(const DataTensor& tensor) {
439439
case DataLayout::bs_fs_zyx_bsv32_fsv16:
440440
return 32;
441441
default:
442-
OPENVINO_ASSERT("GetInnerBatchBlockSize : Unexpected format for eltwise_blocked_optimized kernel.");
442+
OPENVINO_THROW("GetInnerBatchBlockSize : Unexpected format for eltwise_blocked_optimized kernel.");
443443
}
444444

445445
return 1;
@@ -465,7 +465,7 @@ static inline int GetInnerFeatureBlockSize(const DataTensor& tensor) {
465465
case DataLayout::bs_fs_zyx_bsv16_fsv32:
466466
return 32;
467467
default:
468-
OPENVINO_ASSERT("GetInnerFeatureBlockSize : Unexpected format for eltwise_blocked_optimized kernel.");
468+
OPENVINO_THROW("GetInnerFeatureBlockSize : Unexpected format for eltwise_blocked_optimized kernel.");
469469
}
470470

471471
return 1;

src/plugins/intel_gpu/src/plugin/ops/scatter_elements_update.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ static void CreateScatterElementsUpdateOp(ProgramBuilder& p, const std::shared_p
1818
std::string layerName = layer_type_name_ID(op);
1919

2020
auto axes_constant = std::dynamic_pointer_cast<ov::op::v0::Constant>(op->get_input_node_shared_ptr(3));
21-
if (!axes_constant) {
22-
OPENVINO_ASSERT("Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")");
23-
}
21+
OPENVINO_ASSERT(axes_constant, "Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")");
22+
2423
int64_t axis = ov::util::normalize_axis(op.get(), axes_constant->cast_vector<int64_t>()[0], op->get_input_partial_shape(0).rank());
2524

2625
auto mode = cldnn::ScatterElementsUpdateOp::Reduction::NONE;

src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3206,7 +3206,7 @@ TEST(eltwise_gpu_f32, broadcast_test_dim3_dim4) {
32063206
// in1:dim3, int2:dim4
32073207
{
32083208
ov::Shape in1_shape = {2, 4, 2};
3209-
3209+
32103210
auto input = engine.allocate_memory({ ov::PartialShape(in1_shape), data_types::f32, format::bfyx });
32113211
set_values(input, const_input);
32123212

@@ -3239,7 +3239,7 @@ TEST(eltwise_gpu_f32, broadcast_test_dim3_dim4) {
32393239
// So explicit 4d input shpae {1, 2, 4, 2} should have same result from input{2, 4, 2}
32403240
{
32413241
ov::Shape in1_shape = {1, 2, 4, 2};
3242-
3242+
32433243
auto input = engine.allocate_memory({ ov::PartialShape(in1_shape), data_types::f32, format::bfyx });
32443244
set_values(input, const_input);
32453245

@@ -4506,7 +4506,7 @@ struct eltwise_layout_test_params {
45064506
};
45074507

45084508
#define CASE_ELTWISE_TEST1 eltwise_mode::sum, {1, 2, 1, 1}, {4, 2, 4, 4}, format::b_fs_yx_fsv16, format::bfyx, "generic_eltwise_ref"
4509-
#define CASE_ELTWISE_TEST2 eltwise_mode::sum, {4, 1, 4, 4}, {1, 5, 1, 1}, format::b_fs_yx_fsv16, format::bfyx, "eltwise_blocked_opt"
4509+
#define CASE_ELTWISE_TEST2 eltwise_mode::sum, {4, 1, 4, 4}, {1, 5, 1, 1}, format::b_fs_yx_fsv16, format::bfyx, "generic_eltwise_ref"
45104510
#define CASE_ELTWISE_TEST3 eltwise_mode::sum, {4, 5, 4, 1}, {4, 1, 4, 1}, format::b_fs_yx_fsv16, format::bfyx, "generic_eltwise_ref"
45114511
#define CASE_ELTWISE_TEST4 eltwise_mode::sum, {4, 2, 4, 4}, {1, 1, 1, 1}, format::b_fs_yx_fsv16, format::bfyx, "eltwise_blocked_opt"
45124512
#define CASE_ELTWISE_TEST5 eltwise_mode::sum, {1, 2, 1, 1}, {4, 2, 4, 4}, format::bfyx, format::b_fs_yx_fsv16, "generic_eltwise_ref"

src/plugins/intel_gpu/tests/unit/test_cases/reshape_gpu_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ void test_calc_output_shape(bool is_caching_test) {
502502

503503
topology topology;
504504
topology.add(input_layout("input", input->get_layout()));
505-
topology.add(reshape("reshape", input_info("input"), tensor(1, 1, 0, -1)));
505+
topology.add(reshape("reshape", input_info("input"), tensor(1, 1, 1, -1)));
506506

507507
set_values(input, {-1.f, 2.f, -3.f, 4.f});
508508

0 commit comments

Comments
 (0)