Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPUW] Fixed oob in case of permute_021 int4 and num_channels > 1 (#32100)

Eugene Smirnov52c8d8d591a3
diff --git a/src/plugins/intel_npu/src/plugin/npuw/util.cpp b/src/plugins/intel_npu/src/plugin/npuw/util.cpp
index 83a2ab4c038..3d96daa5c75 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/util.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/util.cpp
@@ -671,8 +671,8 @@ ov::Tensor ov::npuw::util::permute(const ov::Tensor& t, const std::vector<std::s
const uint8_t* src = static_cast<const uint8_t*>(t.data());
uint8_t* dst = static_cast<uint8_t*>(tnew.data());
ov::parallel_for(shape[0], [&](size_t p) {
- const uint8_t* src_ptr = src + p * shape[1] * shape[2];
- uint8_t* dst_ptr = dst + p * shape[1] * shape[2];
+ const uint8_t* src_ptr = src + p * shape[1] * shape[2] / 2;
+ uint8_t* dst_ptr = dst + p * shape[1] * shape[2] / 2;
ov::npuw::util::XARCH::transpose_i4(src_ptr, dst_ptr, shape[1], shape[2]);
});
break;
diff --git a/src/plugins/intel_npu/tests/unit/npuw/permute.cpp b/src/plugins/intel_npu/tests/unit/npuw/permute.cpp
index 522ef2a64b1..c48bda09419 100644
--- a/src/plugins/intel_npu/tests/unit/npuw/permute.cpp
+++ b/src/plugins/intel_npu/tests/unit/npuw/permute.cpp
@@ -195,6 +195,9 @@ const auto TestCases021 = ::testing::Combine(
, Tensors {
input = {1, 16, 300};
}
+, Tensors {
+ input = {32,128,1288};
+}
}),
::testing::ValuesIn(
{
diff --git a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp
index 0e1f632312c..391565deed2 100644
--- a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp
+++ b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp
@@ -366,12 +366,22 @@ inline bool less_or_equal(double a, double b) {
return less(a, b) || equal(a, b);
}
+template <typename T>
+inline constexpr bool is_ov_integral =
+ std::is_same_v<T, char> || std::is_same_v<T, int8_t> || std::is_same_v<T, int16_t> || std::is_same_v<T, int32_t> ||
+ std::is_same_v<T, int64_t> || std::is_same_v<T, uint8_t> || std::is_same_v<T, uint16_t> ||
+ std::is_same_v<T, uint32_t> || std::is_same_v<T, uint64_t>;
+
template <typename T>
inline bool value_is_out_of_limits(T value, bool upper_bound_check) {
- bool out_of_limits = std::isnan(value) || std::isinf(value);
- out_of_limits |=
- upper_bound_check ? value >= std::numeric_limits<T>::max() : value <= std::numeric_limits<T>::lowest();
- return out_of_limits;
+ if constexpr (is_ov_integral<T>) {
+ return false;
+ } else {
+ bool out_of_limits = std::isnan(value) || std::isinf(value);
+ out_of_limits |=
+ upper_bound_check ? value >= std::numeric_limits<T>::max() : value <= std::numeric_limits<T>::lowest();
+ return out_of_limits;
+ }
}
template <typename T1, typename T2>