diff --git a/.github/workflows/job_onnx_runtime.yml b/.github/workflows/job_onnx_runtime.yml index 194d27d0f798e5..31420d793b14cd 100644 --- a/.github/workflows/job_onnx_runtime.yml +++ b/.github/workflows/job_onnx_runtime.yml @@ -93,8 +93,10 @@ jobs: - name: Clone ONNX Runtime run: | - branch=`tr -s '\n ' < ${ONNX_RUNTIME_UTILS}/version` - git clone --branch $branch --single-branch --recursive https://github.com/microsoft/onnxruntime.git ${ONNX_RUNTIME_REPO} + hash=`tr -s '\n ' < ${ONNX_RUNTIME_UTILS}/version` + git clone --recursive https://github.com/microsoft/onnxruntime.git ${ONNX_RUNTIME_REPO} + cd ${ONNX_RUNTIME_REPO} + git checkout $hash # # Tests @@ -114,7 +116,7 @@ jobs: ${ONNX_RUNTIME_REPO}/build.sh \ --config RelWithDebInfo \ - --use_openvino CPU_FP32 \ + --use_openvino CPU \ --build_shared_lib \ --parallel \ --skip_tests \ @@ -130,6 +132,11 @@ jobs: - name: Run onnxruntime_test_all if: ${{ runner.arch != 'ARM64' }} # Ticket: 126277 run: | + # see https://github.com/microsoft/onnxruntime/issues/13197#issuecomment-1264542497 + apt-get install --assume-yes --no-install-recommends language-pack-en + locale-gen en_US.UTF-8 + update-locale LANG=en_US.UTF-8 + source ${INSTALL_DIR}/setupvars.sh skip_tests=$(tr -s '\n ' ':' < ${ONNX_RUNTIME_UTILS}/skip_tests) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 319fa055c807b3..213f55d89a392f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -449,10 +449,8 @@ jobs: ONNX_Runtime: name: ONNX Runtime Integration - # Enable back once https://github.com/microsoft/onnxruntime/pull/19184 is merged - if: ${{ 'false' }} - # if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT || - # fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE + if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT || + fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE needs: [ Build, Smart_CI ] uses: ./.github/workflows/job_onnx_runtime.yml with: diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml index 0c4dceb0cda90b..3f32023bee07e4 100644 --- a/.github/workflows/linux_arm64.yml +++ b/.github/workflows/linux_arm64.yml @@ -333,10 +333,8 @@ jobs: ONNX_Runtime: name: ONNX Runtime Integration - # Enable back once https://github.com/microsoft/onnxruntime/pull/19184 is merged - if: ${{ 'false' }} - # if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT || - # fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE + if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT || + fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE needs: [ Build, Smart_CI ] uses: ./.github/workflows/job_onnx_runtime.yml with: diff --git a/.github/workflows/linux_riscv.yml b/.github/workflows/linux_riscv.yml index d764c1f96c1645..6e63f2c44faee2 100644 --- a/.github/workflows/linux_riscv.yml +++ b/.github/workflows/linux_riscv.yml @@ -110,6 +110,7 @@ jobs: git submodule update --init -- ${OPENVINO_REPO}/thirdparty/telemetry git submodule update --init -- ${OPENVINO_REPO}/src/plugins/intel_cpu git submodule update --init -- ${OPENVINO_REPO}/thirdparty/open_model_zoo + git submodule update --init -- ${OPENVINO_REPO}/thirdparty/flatbuffers/flatbuffers popd # @@ -192,8 +193,6 @@ jobs: -DENABLE_INTEL_GPU=ON \ -DENABLE_PYTHON=ON \ -DENABLE_WHEEL=ON \ - -DPYTHON_MODULE_EXTENSION=$(riscv64-linux-gnu-python3-config --extension-suffix) \ - -DPYBIND11_PYTHON_EXECUTABLE_LAST=${OPENVINO_BUILD_DIR}/env/bin/python3.10 \ -DENABLE_TESTS=ON \ -DENABLE_PYTHON_PACKAGING=ON \ -DENABLE_SYSTEM_PROTOBUF=ON \ diff --git a/cmake/features.cmake b/cmake/features.cmake index e5fd692a10b309..3cc86bc99f9216 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -151,7 +151,7 @@ else() set(ENABLE_SYSTEM_LIBS_DEFAULT OFF) endif() -if(ANDROID OR RISCV64) +if(CMAKE_CROSSCOMPILING AND (ANDROID OR RISCV64)) # when protobuf from /usr/include is used, then Android / Risc-V toolchain ignores include paths # but if we build for Android using vcpkg / conan / etc where flatbuffers is not located in # the /usr/include folders, we can still use 'system' flatbuffers diff --git a/conan.lock b/conan.lock index 19142643d16ad3..5c01cfd1d37096 100644 --- a/conan.lock +++ b/conan.lock @@ -4,7 +4,7 @@ "xbyak/6.73#250bc3bc73379f90f255876c1c00a4cd%1691853024.351", "snappy/1.1.10#916523630083f6d855cb2977de8eefb6%1689780661.062", "rapidjson/cci.20220822#8ca51918340f3a21127822258e95ec0f%1663194355.698", - "pybind11/2.10.4#dd44c80a5ed6a2ef11194380daae1248%1682692198.909", + "pybind11/2.12.0#1bf487c19d580200ba9b74afcc4174b4%1711607911.876", "pugixml/1.13#f615c1fcec55122b2e177d17061276e7%1691917296.869", "protobuf/3.21.12#d9f5f4e3b86552552dda4c0a2e928eeb%1685218275.69", "opencl-icd-loader/2023.04.17#5f73dd9f0c023d416a7f162e320b9c77%1692732261.088", @@ -31,5 +31,6 @@ "automake/1.16.5#058bda3e21c36c9aa8425daf3c1faf50%1688481772.751", "autoconf/2.71#53be95d228b2dcb30dc199cb84262d8f%1693395343.513" ], - "python_requires": [] + "python_requires": [], + "config_requires": [] } \ No newline at end of file diff --git a/conanfile.txt b/conanfile.txt index 5d9920874a629b..7cbc98e354dc20 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -8,7 +8,7 @@ rapidjson/[>=1.1.0] xbyak/[>=6.62] snappy/[>=1.1.7] onnx/1.15.0 -pybind11/[>=2.10.1] +pybind11/[>=2.12.0] flatbuffers/[>=22.9.24] [tool_requires] diff --git a/src/bindings/python/src/pyopenvino/core/common.cpp b/src/bindings/python/src/pyopenvino/core/common.cpp index 440cba9f69d981..2fc2871159ca4f 100644 --- a/src/bindings/python/src/pyopenvino/core/common.cpp +++ b/src/bindings/python/src/pyopenvino/core/common.cpp @@ -280,8 +280,116 @@ py::array array_from_tensor(ov::Tensor&& t, bool is_shared) { return py::array(dtype, t.get_shape(), t.get_strides(), t.data()); } +py::array array_from_constant_copy(ov::op::v0::Constant&& c) { + const auto& ov_type = c.get_element_type(); + const auto dtype = Common::type_helpers::get_dtype(ov_type); + if (ov_type.bitwidth() < Common::values::min_bitwidth) { + return py::array(dtype, c.get_byte_size(), c.get_data_ptr()); + } + return py::array(dtype, c.get_shape(), constant_helpers::_get_strides(c), c.get_data_ptr()); +} + +py::array array_from_constant_copy(ov::op::v0::Constant&& c, py::dtype& dst_dtype) { + // floating + if (dst_dtype.is(py::dtype("float64"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("float32"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("float16"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } + // signed + else if (dst_dtype.is(py::dtype("int64"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("int32"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("int16"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("int8"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } + // unsigned + else if (dst_dtype.is(py::dtype("uint64"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("uint32"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("uint16"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } else if (dst_dtype.is(py::dtype("uint8"))) { + return array_helpers::array_from_constant_cast(std::forward(c), dst_dtype); + } + // other + else if (dst_dtype.is(py::dtype("bool"))) { + const auto& ov_type = c.get_element_type(); + switch (ov_type) { + case ov::element::f32: + return array_helpers::array_from_constant_cast_bool(std::forward(c), + dst_dtype); + case ov::element::f64: + return array_helpers::array_from_constant_cast_bool(std::forward(c), + dst_dtype); + case ov::element::f16: + return array_helpers::array_from_constant_cast_bool(std::forward(c), + dst_dtype); + default: + return array_helpers::array_from_constant_cast>( + std::forward(c), + dst_dtype); + } + } else { + OPENVINO_THROW("Constant cannot be casted to specified dtype!"); + } +} + +py::array array_from_constant_view(ov::op::v0::Constant&& c) { + const auto& ov_type = c.get_element_type(); + const auto dtype = Common::type_helpers::get_dtype(ov_type); + if (ov_type.bitwidth() < Common::values::min_bitwidth) { + return py::array(dtype, c.get_byte_size(), c.get_data_ptr(), py::cast(c)); + } + return py::array(dtype, c.get_shape(), constant_helpers::_get_strides(c), c.get_data_ptr(), py::cast(c)); +} + }; // namespace array_helpers +namespace constant_helpers { +std::vector _get_strides(const ov::op::v0::Constant& self) { + auto element_type = self.get_element_type(); + auto shape = self.get_shape(); + if (element_type == ov::element::boolean) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::f16 || element_type == ov::element::bf16) { + // WA for bf16, returned as f16 array + return _get_byte_strides(shape); + } else if (element_type == ov::element::f32) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::f64) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::i8 || element_type == ov::element::i4) { + // WA for i4, returned as int8 array + return _get_byte_strides(shape); + } else if (element_type == ov::element::i16) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::i32) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::i64) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::u8 || element_type == ov::element::u1 || element_type == ov::element::u4 || + element_type == ov::element::nf4) { + // WA for u1, u4, nf4, all returned as packed uint8 arrays + return _get_byte_strides(shape); + } else if (element_type == ov::element::u16) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::u32) { + return _get_byte_strides(shape); + } else if (element_type == ov::element::u64) { + return _get_byte_strides(shape); + } else { + throw std::runtime_error("Unsupported data type!"); + } +} +}; // namespace constant_helpers + template <> ov::op::v0::Constant create_copied(py::array& array) { // Do not copy data from the array, only return empty tensor based on type. diff --git a/src/bindings/python/src/pyopenvino/core/common.hpp b/src/bindings/python/src/pyopenvino/core/common.hpp index 7f7341f7925026..a4b52e90ef0750 100644 --- a/src/bindings/python/src/pyopenvino/core/common.hpp +++ b/src/bindings/python/src/pyopenvino/core/common.hpp @@ -82,8 +82,48 @@ py::array as_contiguous(py::array& array, ov::element::Type type); py::array array_from_tensor(ov::Tensor&& t, bool is_shared); +template +py::array array_from_constant_cast_bool(ov::op::v0::Constant&& c, py::dtype& dst_dtype) { + std::vector result; + size_t size = c.get_byte_size() / sizeof(T); + + result.reserve(size); + + for(size_t i = 0; i < size; i++) { + result.emplace_back(*(static_cast(c.get_data_ptr()) + i) != 0 ? 1 : 0); + } + + return py::array(dst_dtype, c.get_shape(), result.data()); +} + +template +py::array array_from_constant_cast(ov::op::v0::Constant&& c, py::dtype& dst_dtype) { + auto tmp = c.cast_vector(); + return py::array(dst_dtype, c.get_shape(), tmp.data()); +} + +py::array array_from_constant_copy(ov::op::v0::Constant&& c); + +py::array array_from_constant_copy(ov::op::v0::Constant&& c, py::dtype& dst_dtype); + +py::array array_from_constant_view(ov::op::v0::Constant&& c); + }; // namespace array_helpers +namespace constant_helpers { +template +std::vector _get_byte_strides(const ov::Shape& s) { + auto byte_strides = ov::row_major_strides(s); + for (auto&& stride : byte_strides) { + stride *= sizeof(T); + } + return byte_strides; +} + +std::vector _get_strides(const ov::op::v0::Constant& self); + +}; // namespace constant_helpers + // Helpers for shapes namespace shape_helpers { diff --git a/src/bindings/python/src/pyopenvino/frontend/manager.cpp b/src/bindings/python/src/pyopenvino/frontend/manager.cpp index 70a39aa9ce77b3..f197d6946f8cab 100644 --- a/src/bindings/python/src/pyopenvino/frontend/manager.cpp +++ b/src/bindings/python/src/pyopenvino/frontend/manager.cpp @@ -99,6 +99,10 @@ void regclass_frontend_FrontEndManager(py::module m) { }); } +OPENVINO_SUPPRESS_DEPRECATED_START + +// CVS-139194: migrate to new exception handling https://github.com/pybind/pybind11/pull/4772 + void regclass_frontend_GeneralFailureFrontEnd(py::module m) { static py::exception exc(std::move(m), "GeneralFailure"); py::register_exception_translator([](std::exception_ptr p) { @@ -158,3 +162,5 @@ void regclass_frontend_NotImplementedFailureFrontEnd(py::module m) { } }); } + +OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/bindings/python/src/pyopenvino/graph/ops/constant.cpp b/src/bindings/python/src/pyopenvino/graph/ops/constant.cpp index b8fe5cfbbe04b4..d5b7e5878e0184 100644 --- a/src/bindings/python/src/pyopenvino/graph/ops/constant.cpp +++ b/src/bindings/python/src/pyopenvino/graph/ops/constant.cpp @@ -17,52 +17,6 @@ namespace py = pybind11; -template -std::vector _get_byte_strides(const ov::Shape& s) { - std::vector byte_strides; - std::vector element_strides = ov::row_major_strides(s); - for (auto v : element_strides) { - byte_strides.push_back(static_cast(v) * sizeof(T)); - } - return byte_strides; -} - -std::vector _get_strides(const ov::op::v0::Constant& self) { - auto element_type = self.get_element_type(); - auto shape = self.get_shape(); - if (element_type == ov::element::boolean) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::f16 || element_type == ov::element::bf16) { - // WA for bf16, returned as f16 array - return _get_byte_strides(shape); - } else if (element_type == ov::element::f32) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::f64) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::i8 || element_type == ov::element::i4) { - // WA for i4, returned as int8 array - return _get_byte_strides(shape); - } else if (element_type == ov::element::i16) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::i32) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::i64) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::u8 || element_type == ov::element::u1 || element_type == ov::element::u4 || - element_type == ov::element::nf4) { - // WA for u1, u4, nf4, all returned as packed uint8 arrays - return _get_byte_strides(shape); - } else if (element_type == ov::element::u16) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::u32) { - return _get_byte_strides(shape); - } else if (element_type == ov::element::u64) { - return _get_byte_strides(shape); - } else { - throw std::runtime_error("Unsupported data type!"); - } -} - // TODO: Remove in future and re-use `get_data` template py::buffer_info _get_buffer_info(const ov::op::v0::Constant& c) { @@ -72,7 +26,7 @@ py::buffer_info _get_buffer_info(const ov::op::v0::Constant& c) { py::format_descriptor::format(), /* Python struct-style format descriptor */ static_cast(shape.size()), /* Number of dimensions */ std::vector{shape.begin(), shape.end()}, /* Buffer dimensions */ - _get_byte_strides(shape) /* Strides (in bytes) for each index */ + Common::constant_helpers::_get_byte_strides(shape) /* Strides (in bytes) for each index */ ); } @@ -80,12 +34,13 @@ py::buffer_info _get_buffer_info(const ov::op::v0::Constant& c) { template <> py::buffer_info _get_buffer_info(const ov::op::v0::Constant& c) { ov::Shape shape = c.get_shape(); - return py::buffer_info(const_cast(c.get_data_ptr()), /* Pointer to buffer */ - static_cast(c.get_element_type().size()), /* Size of one scalar */ - std::string(1, 'H'), /* Python struct-style format descriptor */ - static_cast(shape.size()), /* Number of dimensions */ - std::vector{shape.begin(), shape.end()}, /* Buffer dimensions */ - _get_byte_strides(shape) /* Strides (in bytes) for each index */ + return py::buffer_info( + const_cast(c.get_data_ptr()), /* Pointer to buffer */ + static_cast(c.get_element_type().size()), /* Size of one scalar */ + std::string(1, 'H'), /* Python struct-style format descriptor */ + static_cast(shape.size()), /* Number of dimensions */ + std::vector{shape.begin(), shape.end()}, /* Buffer dimensions */ + Common::constant_helpers::_get_byte_strides(shape) /* Strides (in bytes) for each index */ ); } @@ -201,33 +156,73 @@ void regclass_graph_op_Constant(py::module m) { constant.def( "get_data", - [](ov::op::v0::Constant& self) { - auto ov_type = self.get_element_type(); - auto dtype = Common::type_helpers::get_dtype(ov_type); - if (ov_type.bitwidth() < Common::values::min_bitwidth) { - return py::array(dtype, self.get_byte_size(), self.get_data_ptr()); + [](ov::op::v0::Constant& self, py::object& dtype, bool copy) { + // Destination type was set: + if (!dtype.is(py::none())) { + py::dtype dst_dtype; + if (dtype.is(py::dtype())) { + dst_dtype = dtype.cast(); + } else { + dst_dtype = py::dtype::from_args(dtype); + } + const auto& ov_type = self.get_element_type(); + const auto dtype = Common::type_helpers::get_dtype(ov_type); + // If dtype is the same as Constant type + // casting is NOT required, only check copy flag + if (dst_dtype.is(dtype)) { + if (copy) { + return Common::array_helpers::array_from_constant_copy( + std::forward(self)); + } else { + return Common::array_helpers::array_from_constant_view( + std::forward(self)); + } + } + // Otherwise always copy: + else { + return Common::array_helpers::array_from_constant_copy(std::forward(self), + dst_dtype); + } + } + // Copy of data in Constant type: + else if (copy) { + return Common::array_helpers::array_from_constant_copy(std::forward(self)); + } + // Shared view of data in Constant type: + else { + return Common::array_helpers::array_from_constant_view(std::forward(self)); } - return py::array(dtype, self.get_shape(), _get_strides(self), self.get_data_ptr()); }, + py::kw_only(), + py::arg("dtype") = py::none(), + py::arg("copy") = false, R"( - Access to Constant's data - creates a copy of data. + Access to Constant's data. Returns numpy array with corresponding shape. - Returns numpy array with corresponding shape and dtype. - For Constants with openvino specific element type, such as u1, - it returns linear array, with uint8 / int8 numpy dtype. + Function tries to return a view by default, if not possible due + to types mismatch (between the Constant's type and `dtype`) + or when `copy=True`, then make a copy of data. + If `dtype` is not specified, it's inherited from Constant itself. + + For Constants with OpenVINO specific element type, such as u1, + it returns linear array (as view) with uint8 / int8 numpy dtype. + In such cases if `dtype` is used, function also creates a copy and + unpacks the data. + + Note: can be used to upcast BF16 data type to float32 or float64. + + :param dtype: Targeted data type. + :type dtype: numpy.dtype, optional, keyword-only + :param copy: Enable or disable copy of data. + :type copy: bool, optional, keyword-only :rtype: numpy.array )"); constant.def_property_readonly( "data", [](ov::op::v0::Constant& self) { - auto ov_type = self.get_element_type(); - auto dtype = Common::type_helpers::get_dtype(ov_type); - if (ov_type.bitwidth() < Common::values::min_bitwidth) { - return py::array(dtype, self.get_byte_size(), self.get_data_ptr(), py::cast(self)); - } - return py::array(dtype, self.get_shape(), _get_strides(self), self.get_data_ptr(), py::cast(self)); + return Common::array_helpers::array_from_constant_view(std::forward(self)); }, R"( Access to Constant's data - creates a view of data. diff --git a/src/bindings/python/tests/test_graph/test_constant.py b/src/bindings/python/tests/test_graph/test_constant.py index 6f13d0911b0c1a..8d9ec4f183397e 100644 --- a/src/bindings/python/tests/test_graph/test_constant.py +++ b/src/bindings/python/tests/test_graph/test_constant.py @@ -533,3 +533,184 @@ def test_float_to_f8e4m3_convert(ov_type, numpy_dtype): target = np.array(target, dtype=numpy_dtype) assert np.allclose(result, target, equal_nan=True) + + +@pytest.mark.parametrize( + ("src_dtype"), + [ + (np.float16), + (np.float32), + (np.float64), + (np.int8), + (np.uint8), + (np.int16), + (np.uint16), + (np.int32), + (np.uint32), + (np.int64), + (np.bool_), + ], +) +@pytest.mark.parametrize( + ("dst_dtype"), + [ + (None), + (np.float16), + (np.float32), + (np.float64), + (np.int8), + (np.uint8), + (np.int16), + (np.uint16), + (np.int32), + (np.uint32), + (np.int64), + (np.bool_), + ], +) +@pytest.mark.parametrize( + ("copy_flag"), + [ + (True), + (False), + ], +) +def test_get_data_casting(src_dtype, dst_dtype, copy_flag): + data = np.random.rand(2, 4, 16) + 0.01 # do not allow 0s -- extra edge-case for bool type + data = data.astype(src_dtype) + + ov_const = ops.constant(data, dtype=src_dtype) + arr = ov_const.get_data(dtype=dst_dtype, copy=copy_flag) + + if (src_dtype == dst_dtype or dst_dtype is None) and copy_flag is False: + assert arr.flags["OWNDATA"] is False + assert np.array_equal(arr, data) + else: + assert arr.flags["OWNDATA"] is True + assert np.array_equal(arr, data.astype(dst_dtype)) + + +@pytest.mark.parametrize( + ("src_dtype"), + [ + (np.float16), + (np.float32), + (np.float64), + (np.int8), + (np.uint8), + (np.int16), + (np.uint16), + (np.int32), + (np.uint32), + (np.int64), + (np.bool_), + ], +) +@pytest.mark.parametrize( + ("copy_flag"), + [ + (True), + (False), + ], +) +def test_get_data_casting_bool(src_dtype, copy_flag): + data = np.array([1.0, 0.0, 2.0, 0.5, 0.3, 0.1, 3.0]).astype(src_dtype) + + ov_const = ops.constant(data, dtype=src_dtype) + arr = ov_const.get_data(dtype=np.bool_, copy=copy_flag) + + if src_dtype == np.bool_ and copy_flag is False: + assert arr.flags["OWNDATA"] is False + assert np.array_equal(arr, data) + else: + assert arr.flags["OWNDATA"] is True + assert np.array_equal(arr, data.astype(np.bool_)) + + +@pytest.mark.parametrize( + ("src_dtype"), + [ + (np.float16), + (np.float32), + (np.float64), + ], +) +@pytest.mark.parametrize( + ("dst_dtype"), + [ + (None), + (np.float16), + (np.float32), + (np.float64), + ], +) +@pytest.mark.parametrize( + ("copy_flag"), + [ + (True), + (False), + ], +) +def test_get_data_casting_bf16(src_dtype, dst_dtype, copy_flag): + data = np.array([1.0, 0.0, 1012.5, 0.5, 2.0]).astype(src_dtype) + ov_const = ops.constant(data, dtype=Type.bf16) + + arr = ov_const.get_data(dtype=dst_dtype, copy=copy_flag) + + expected_result = np.array([1.0, 0.0, 1012.0, 0.5, 2.0], dtype=np.float32) + + if dst_dtype is None and copy_flag is False: + assert arr.flags["OWNDATA"] is False + assert arr.dtype == np.float16 + assert np.array_equal(arr.view(np.int16), expected_result.view(np.int16)[1::2]) + elif dst_dtype == np.float16 and copy_flag is False: + assert arr.flags["OWNDATA"] is False + assert np.array_equal(arr.view(np.int16), expected_result.view(np.int16)[1::2]) + else: # copy_flag is True + assert arr.flags["OWNDATA"] is True + if dst_dtype in [None, np.float16]: + assert np.array_equal(arr.view(np.int16), expected_result.view(np.int16)[1::2]) + else: # up-casting to np.float32 or np.float64 + assert np.array_equal(arr, expected_result) + + +@pytest.mark.parametrize( + ("src_dtype"), + [ + (np.int8), + ], +) +@pytest.mark.parametrize( + ("ov_type"), + [ + (Type.u1), + ], +) +@pytest.mark.parametrize( + ("dst_dtype"), + [ + (None), + (np.int8), + ], +) +@pytest.mark.parametrize( + ("copy_flag"), + [ + (True), + (False), + ], +) +def test_get_data_casting_packed(src_dtype, ov_type, dst_dtype, copy_flag): + data = np.array([[0, 0, 0, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1]], dtype=src_dtype) + ov_const = ops.constant(data, dtype=ov_type) + arr = ov_const.get_data(dtype=dst_dtype, copy=copy_flag) + + if dst_dtype is None: + if copy_flag: + assert arr.flags["OWNDATA"] is True + else: + assert arr.flags["OWNDATA"] is False + assert np.array_equal(arr, np.packbits(data)) + else: + assert arr.flags["OWNDATA"] is True + assert np.array_equal(arr, data) diff --git a/src/bindings/python/thirdparty/pybind11 b/src/bindings/python/thirdparty/pybind11 index 2965fa8de3cf9e..3e9dfa28669416 160000 --- a/src/bindings/python/thirdparty/pybind11 +++ b/src/bindings/python/thirdparty/pybind11 @@ -1 +1 @@ -Subproject commit 2965fa8de3cf9e82c789f906a525a76197b186c1 +Subproject commit 3e9dfa2866941655c56877882565e7577de6fc7b diff --git a/src/frontends/onnx/tests/ci_utils/onnxruntime/version b/src/frontends/onnx/tests/ci_utils/onnxruntime/version index d2452e2d7b872b..140dc28bbbe02b 100644 --- a/src/frontends/onnx/tests/ci_utils/onnxruntime/version +++ b/src/frontends/onnx/tests/ci_utils/onnxruntime/version @@ -1,2 +1 @@ -rel-1.16.2 - +a457c1df80f391ea6de0ab1d454297716976dbf3 \ No newline at end of file diff --git a/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp b/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp index db47593d895bf2..acf106f6549615 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp @@ -84,7 +84,8 @@ void reserve_cpu_by_streams_info(const std::vector> _streams_in std::vector>& _stream_processors, const int _cpu_status) { std::vector> streams_table; - std::vector> stream_conditions; + std::vector>> stream_conditions; + std::vector> threads_status; // used to count the number of threads std::vector stream_pos; std::vector stream_num; int num_streams = 0; @@ -100,13 +101,14 @@ void reserve_cpu_by_streams_info(const std::vector> _streams_in } num_conditions = static_cast(stream_pos.size()); _stream_processors.assign(num_streams, std::vector()); - stream_conditions.assign(num_conditions, std::vector()); + stream_conditions.assign(num_conditions, std::vector>()); + threads_status.assign(num_conditions, std::vector()); stream_num.assign(num_conditions, 0); for (size_t i = 0; i < _streams_info_table.size(); i++) { - std::vector proc_types; - std::vector numa_nodes; - std::vector sockets; + std::string proc_type = ""; + std::string numa_node = ""; + std::string socket = ""; if (_streams_info_table[i][NUMBER_OF_STREAMS] != 0) { streams_table.push_back(_streams_info_table[i]); if (_streams_info_table[i][NUMBER_OF_STREAMS] < 0) { @@ -118,22 +120,20 @@ void reserve_cpu_by_streams_info(const std::vector> _streams_in condition_idx++; } if (_streams_info_table[i][PROC_TYPE] > ALL_PROC) { - proc_types.push_back(std::to_string(_streams_info_table[i][PROC_TYPE])); + proc_type = std::to_string(_streams_info_table[i][PROC_TYPE]); } else { last_all_proc = true; } if (_streams_info_table[i][STREAM_NUMA_NODE_ID] >= 0) { - numa_nodes.push_back(std::to_string(_streams_info_table[i][STREAM_NUMA_NODE_ID])); + numa_node = std::to_string(_streams_info_table[i][STREAM_NUMA_NODE_ID]); } if (_streams_info_table[i][STREAM_SOCKET_ID] >= 0) { - sockets.push_back(std::to_string(_streams_info_table[i][STREAM_SOCKET_ID])); + socket = std::to_string(_streams_info_table[i][STREAM_SOCKET_ID]); } - for (auto t : proc_types) { - for (auto n : numa_nodes) { - for (auto s : sockets) { - stream_conditions[condition_idx].push_back(t + n + s); - } - } + if (proc_type != "") { + stream_conditions[condition_idx].push_back( + std::make_pair(proc_type + numa_node + socket, _streams_info_table[i][THREADS_PER_STREAM])); + threads_status[condition_idx].push_back(0); } if (_streams_info_table[i][PROC_TYPE] > ALL_PROC && _streams_info_table[i][NUMBER_OF_STREAMS] > 0) { condition_idx++; @@ -146,8 +146,20 @@ void reserve_cpu_by_streams_info(const std::vector> _streams_in std::to_string(_cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID]) + std::to_string(_cpu_mapping_table[i][CPU_MAP_SOCKET_ID]); for (size_t j = 0; j < stream_conditions.size(); j++) { - if (std::find(stream_conditions[j].begin(), stream_conditions[j].end(), cpu_string) != - stream_conditions[j].end()) { + auto iter = std::find_if(stream_conditions[j].begin(), + stream_conditions[j].end(), + [&](std::pair item) { + return cpu_string == item.first; + }); + if (iter != stream_conditions[j].end()) { + // process the situation of proc_type = ALL_PROC + if (stream_conditions[j].size() > 1) { + size_t idx = iter - stream_conditions[j].begin(); + threads_status[j][idx]++; + if (threads_status[j][idx] >= stream_conditions[j][idx].second) { + stream_conditions[j][idx] = std::make_pair("", 0); + } + } _stream_processors[stream_pos[j]].push_back(_cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID]); _cpu_mapping_table[i][CPU_MAP_USED_FLAG] = _cpu_status; if (static_cast(_stream_processors[stream_pos[j]].size()) == diff --git a/src/inference/src/os/cpu_map_info.hpp b/src/inference/src/os/cpu_map_info.hpp index e21f5b5667ab1a..c4389a4cd6c2ea 100644 --- a/src/inference/src/os/cpu_map_info.hpp +++ b/src/inference/src/os/cpu_map_info.hpp @@ -13,6 +13,7 @@ #include #include "dev/threading/parallel_custom_arena.hpp" +#include "openvino/util/log.hpp" namespace ov { @@ -20,6 +21,24 @@ class CPU { public: CPU(); ~CPU(){}; + void cpu_debug() { + OPENVINO_DEBUG << "[ threading ] cpu_mapping_table:"; + for (size_t i = 0; i < _cpu_mapping_table.size(); i++) { + OPENVINO_DEBUG << _cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID] << " " + << _cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] << " " + << _cpu_mapping_table[i][CPU_MAP_SOCKET_ID] << " " << _cpu_mapping_table[i][CPU_MAP_CORE_ID] + << " " << _cpu_mapping_table[i][CPU_MAP_CORE_TYPE] << " " + << _cpu_mapping_table[i][CPU_MAP_GROUP_ID] << " " + << _cpu_mapping_table[i][CPU_MAP_USED_FLAG]; + } + OPENVINO_DEBUG << "[ threading ] org_proc_type_table:"; + for (size_t i = 0; i < _proc_type_table.size(); i++) { + OPENVINO_DEBUG << _proc_type_table[i][ALL_PROC] << " " << _proc_type_table[i][MAIN_CORE_PROC] << " " + << _proc_type_table[i][EFFICIENT_CORE_PROC] << " " + << _proc_type_table[i][HYPER_THREADING_PROC] << " " << _proc_type_table[i][PROC_NUMA_NODE_ID] + << " " << _proc_type_table[i][PROC_SOCKET_ID]; + } + } int _processors = 0; int _numa_nodes = 0; int _sockets = 0; diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cpp index 7c2a1f437821a6..4cb95accbc360a 100644 --- a/src/inference/src/os/lin/lin_system_conf.cpp +++ b/src/inference/src/os/lin/lin_system_conf.cpp @@ -14,7 +14,6 @@ #include "dev/threading/parallel_custom_arena.hpp" #include "openvino/core/except.hpp" #include "openvino/runtime/system_conf.hpp" -#include "openvino/util/log.hpp" #include "os/cpu_map_info.hpp" namespace ov { @@ -279,20 +278,7 @@ CPU::CPU() { _org_proc_type_table = _proc_type_table; - OPENVINO_DEBUG << "[ threading ] cpu_mapping_table:"; - for (size_t i = 0; i < _cpu_mapping_table.size(); i++) { - OPENVINO_DEBUG << _cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID] << " " - << _cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] << " " << _cpu_mapping_table[i][CPU_MAP_SOCKET_ID] - << " " << _cpu_mapping_table[i][CPU_MAP_CORE_ID] << " " - << _cpu_mapping_table[i][CPU_MAP_CORE_TYPE] << " " << _cpu_mapping_table[i][CPU_MAP_GROUP_ID] - << " " << _cpu_mapping_table[i][CPU_MAP_USED_FLAG]; - } - OPENVINO_DEBUG << "[ threading ] org_proc_type_table:"; - for (size_t i = 0; i < _proc_type_table.size(); i++) { - OPENVINO_DEBUG << _proc_type_table[i][ALL_PROC] << " " << _proc_type_table[i][MAIN_CORE_PROC] << " " - << _proc_type_table[i][EFFICIENT_CORE_PROC] << " " << _proc_type_table[i][HYPER_THREADING_PROC] - << " " << _proc_type_table[i][PROC_NUMA_NODE_ID] << " " << _proc_type_table[i][PROC_SOCKET_ID]; - } + cpu_debug(); } void parse_node_info_linux(const std::vector node_info_table, diff --git a/src/inference/src/os/mac/mac_system_conf.cpp b/src/inference/src/os/mac/mac_system_conf.cpp index acc0240e3056a5..4c1eb703224eff 100644 --- a/src/inference/src/os/mac/mac_system_conf.cpp +++ b/src/inference/src/os/mac/mac_system_conf.cpp @@ -31,6 +31,8 @@ CPU::CPU() { parse_processor_info_macos(system_info_table, _processors, _numa_nodes, _sockets, _cores, _proc_type_table); _org_proc_type_table = _proc_type_table; + + cpu_debug(); } void parse_processor_info_macos(const std::vector>& system_info_table, diff --git a/src/inference/src/os/win/win_system_conf.cpp b/src/inference/src/os/win/win_system_conf.cpp index c730b8b1ce717b..f0ea4f181896ac 100644 --- a/src/inference/src/os/win/win_system_conf.cpp +++ b/src/inference/src/os/win/win_system_conf.cpp @@ -51,6 +51,8 @@ CPU::CPU() { _socketid_mapping_table.insert({socket_id, socket_id}); } } + + cpu_debug(); } void parse_processor_info_win(const char* base_ptr, diff --git a/src/inference/tests/unit/cpu_reserve_test.cpp b/src/inference/tests/unit/cpu_reserve_test.cpp index 593a183ce95b24..327bcff7499688 100644 --- a/src/inference/tests/unit/cpu_reserve_test.cpp +++ b/src/inference/tests/unit/cpu_reserve_test.cpp @@ -1182,6 +1182,54 @@ LinuxCpuReserveTestCase _1socket_32cores_hyper_1streams = { NOT_USED, }; +LinuxCpuReserveTestCase _1socket_22cores_MTL_1streams_6threads = { + 22, + 1, + {{22, 6, 10, 6, 0, 0}}, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, EFFICIENT_CORE_PROC, 1, -1}, {3, 0, 0, 2, EFFICIENT_CORE_PROC, 1, -1}, + {4, 0, 0, 3, EFFICIENT_CORE_PROC, 1, -1}, {5, 0, 0, 4, EFFICIENT_CORE_PROC, 1, -1}, + {6, 0, 0, 5, EFFICIENT_CORE_PROC, 2, -1}, {7, 0, 0, 6, EFFICIENT_CORE_PROC, 2, -1}, + {8, 0, 0, 7, EFFICIENT_CORE_PROC, 2, -1}, {9, 0, 0, 8, EFFICIENT_CORE_PROC, 2, -1}, + {10, 0, 0, 9, HYPER_THREADING_PROC, 3, -1}, {11, 0, 0, 9, MAIN_CORE_PROC, 3, -1}, + {12, 0, 0, 10, HYPER_THREADING_PROC, 4, -1}, {13, 0, 0, 10, MAIN_CORE_PROC, 4, -1}, + {14, 0, 0, 11, HYPER_THREADING_PROC, 5, -1}, {15, 0, 0, 11, MAIN_CORE_PROC, 5, -1}, + {16, 0, 0, 12, HYPER_THREADING_PROC, 6, -1}, {17, 0, 0, 12, MAIN_CORE_PROC, 6, -1}, + {18, 0, 0, 13, HYPER_THREADING_PROC, 7, -1}, {19, 0, 0, 13, MAIN_CORE_PROC, 7, -1}, + {20, 0, 0, 14, EFFICIENT_CORE_PROC, -100, -100}, {21, 0, 0, 15, EFFICIENT_CORE_PROC, -100, -100}, + }, + {{1, MAIN_CORE_PROC, 6, 0, 0}}, + { + {1, 11, 13, 15, 17, 19}, + }, + NOT_USED, +}; + +LinuxCpuReserveTestCase _1socket_22cores_MTL_1streams_7threads = { + 22, + 1, + {{22, 6, 10, 6, 0, 0}}, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, EFFICIENT_CORE_PROC, 1, -1}, {3, 0, 0, 2, EFFICIENT_CORE_PROC, 1, -1}, + {4, 0, 0, 3, EFFICIENT_CORE_PROC, 1, -1}, {5, 0, 0, 4, EFFICIENT_CORE_PROC, 1, -1}, + {6, 0, 0, 5, EFFICIENT_CORE_PROC, 2, -1}, {7, 0, 0, 6, EFFICIENT_CORE_PROC, 2, -1}, + {8, 0, 0, 7, EFFICIENT_CORE_PROC, 2, -1}, {9, 0, 0, 8, EFFICIENT_CORE_PROC, 2, -1}, + {10, 0, 0, 9, HYPER_THREADING_PROC, 3, -1}, {11, 0, 0, 9, MAIN_CORE_PROC, 3, -1}, + {12, 0, 0, 10, HYPER_THREADING_PROC, 4, -1}, {13, 0, 0, 10, MAIN_CORE_PROC, 4, -1}, + {14, 0, 0, 11, HYPER_THREADING_PROC, 5, -1}, {15, 0, 0, 11, MAIN_CORE_PROC, 5, -1}, + {16, 0, 0, 12, HYPER_THREADING_PROC, 6, -1}, {17, 0, 0, 12, MAIN_CORE_PROC, 6, -1}, + {18, 0, 0, 13, HYPER_THREADING_PROC, 7, -1}, {19, 0, 0, 13, MAIN_CORE_PROC, 7, -1}, + {20, 0, 0, 14, EFFICIENT_CORE_PROC, -100, -100}, {21, 0, 0, 15, EFFICIENT_CORE_PROC, -100, -100}, + }, + {{1, ALL_PROC, 7, 0, 0}, {0, MAIN_CORE_PROC, 6, 0, 0}, {0, EFFICIENT_CORE_PROC, 1, 0, 0}}, + { + {1, 2, 11, 13, 15, 17, 19}, + }, + NOT_USED, +}; + TEST_P(LinuxCpuReserveTests, LinuxCpuReserve) {} INSTANTIATE_TEST_SUITE_P(CPUReserve, @@ -1209,6 +1257,8 @@ INSTANTIATE_TEST_SUITE_P(CPUReserve, _1socket_18cores_hyper_1streams, _1socket_18cores_hyper_2streams, _1socket_18cores_hyper_plugin_reserve_2threads, - _1socket_32cores_hyper_1streams)); + _1socket_32cores_hyper_1streams, + _1socket_22cores_MTL_1streams_6threads, + _1socket_22cores_MTL_1streams_7threads)); #endif } // namespace diff --git a/src/plugins/intel_cpu/src/nodes/broadcast.cpp b/src/plugins/intel_cpu/src/nodes/broadcast.cpp index 4662e362475bde..ac8dd814ae9961 100644 --- a/src/plugins/intel_cpu/src/nodes/broadcast.cpp +++ b/src/plugins/intel_cpu/src/nodes/broadcast.cpp @@ -103,8 +103,7 @@ void Broadcast::getSupportedDescriptors() { void Broadcast::initSupportedPrimitiveDescriptors() { if (!supportedPrimitiveDescriptors.empty()) return; - - supportedPrimitiveDescriptors = getSupportedConfigs(this); + supportedPrimitiveDescriptors = getSupportedConfigs(this, outputShapes.size()); } bool Broadcast::needPrepareParams() const { diff --git a/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp b/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp index 8ddc5aa39c64ba..6c62304ab22da7 100644 --- a/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp +++ b/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp @@ -90,7 +90,7 @@ bool TileBroadcastCommon::canBeExecutedInNSPCLayout(VectorDims srcBlockedDims, V return optimizedDims.size() <= maxNDims; } -std::vector TileBroadcastCommon::getSupportedConfigs(const Node *node) { +std::vector TileBroadcastCommon::getSupportedConfigs(const Node *node, size_t outSize) { std::vector supportedPrimitiveDescriptors; auto precision = node->getOriginalInputPrecisionAtPort(0); auto dataType = DnnlExtensionUtils::ElementTypeToDataType(precision); @@ -122,7 +122,7 @@ std::vector TileBroadcastCommon::getSupportedConfigs(const Node *node) config.inConfs[2].setMemDesc(std::make_shared(ov::element::i32, node->getInputShapeAtPort(2))); } - config.outConfs.resize(node->getChildEdges().size()); + config.outConfs.resize(outSize); auto pushDesc = [&](dnnl::memory::format_tag inFormat, dnnl::memory::format_tag outFormat) { config.inConfs[0].setMemDesc(std::make_shared(node->getInputShapeAtPort(0), dataType, inFormat)); diff --git a/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.h b/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.h index a865e6cb239b1a..7ae0eacbccd373 100644 --- a/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.h +++ b/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.h @@ -16,7 +16,7 @@ namespace intel_cpu { class TileBroadcastCommon { protected: static VectorDims calculateDenseStrides(const VectorDims &dims); - std::vector getSupportedConfigs(const Node *node); + std::vector getSupportedConfigs(const Node *node, size_t outSize); bool prepareOptimizedParams(const Node *node, VectorDims& srcBlockedDims, VectorDims& dstBlockedDims); void optimizedExecute(const MemoryPtr& srcMemory, const MemoryPtr& dstMemory); diff --git a/src/plugins/intel_cpu/src/nodes/tile.cpp b/src/plugins/intel_cpu/src/nodes/tile.cpp index 75e0c01cf4a36e..447898e6390342 100644 --- a/src/plugins/intel_cpu/src/nodes/tile.cpp +++ b/src/plugins/intel_cpu/src/nodes/tile.cpp @@ -110,7 +110,7 @@ void Tile::initSupportedPrimitiveDescriptors() { if (!supportedPrimitiveDescriptors.empty()) return; - supportedPrimitiveDescriptors = getSupportedConfigs(this); + supportedPrimitiveDescriptors = getSupportedConfigs(this, outputShapes.size()); } bool Tile::needPrepareParams() const { diff --git a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d.py b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d.py index 0af9ec7c31632f..46d19efd36ce3b 100644 --- a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d.py +++ b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d.py @@ -60,6 +60,7 @@ def create_keras_conv3d_net(self, conv_params, input_names, input_shapes, input_ @pytest.mark.parametrize("params", test_data_float32) @pytest.mark.precommit @pytest.mark.nightly + @pytest.mark.xfail(reason="timeout issue for inference") def test_keras_conv_3d_float32(self, params, ie_device, precision, ir_version, temp_dir, use_legacy_frontend): self._test(*self.create_keras_conv3d_net(**params, ir_version=ir_version), ie_device, diff --git a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d_transpose.py b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d_transpose.py index 518db5a006ee1b..c1337452c63f02 100644 --- a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d_transpose.py +++ b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_3d_transpose.py @@ -1,9 +1,10 @@ # Copyright (C) 2022-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import platform + import pytest import tensorflow as tf - from common.tf2_layer_test_class import CommonTF2LayerTest @@ -59,6 +60,8 @@ def create_keras_conv_3d_transpose_net(self, conv_params, input_names, input_sha @pytest.mark.nightly def test_keras_conv_3D_transpose_float32(self, params, ie_device, precision, ir_version, temp_dir, use_legacy_frontend): + if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']: + pytest.skip("timeout issue for inference on ARM") self._test(*self.create_keras_conv_3d_transpose_net(**params, ir_version=ir_version), ie_device, precision, temp_dir=temp_dir, ir_version=ir_version, diff --git a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_gru.py b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_gru.py index 3379868eff457c..7e59b448e1fec5 100644 --- a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_gru.py +++ b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_gru.py @@ -102,6 +102,7 @@ def test_keras_gru_without_bias_float32(self, params, ie_device, precision, temp @pytest.mark.parametrize("params", test_data_different_flags) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.xfail(reason="sporadic inference mismatch") def test_keras_gru_flags_float32(self, params, ie_device, precision, temp_dir, ir_version, use_legacy_frontend): self._test(*self.create_keras_gru_net(**params, ir_version=ir_version), diff --git a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_lstm.py b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_lstm.py index 1d893972779ae8..d54e3ebe588dcd 100644 --- a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_lstm.py +++ b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_lstm.py @@ -1,9 +1,10 @@ # Copyright (C) 2022-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import platform + import pytest import tensorflow as tf - from common.tf2_layer_test_class import CommonTF2LayerTest @@ -100,6 +101,8 @@ def test_keras_lstm_without_bias_float32(self, params, ie_device, precision, tem @pytest.mark.precommit def test_keras_lstm_flags_float32(self, params, ie_device, precision, temp_dir, ir_version, use_legacy_frontend): + if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']: + pytest.skip("inference mismatch issue on ARM") self._test(*self.create_keras_lstm_net(**params, ir_version=ir_version), ie_device, precision, temp_dir=temp_dir, ir_version=ir_version, use_legacy_frontend=use_legacy_frontend, **params) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_BinaryOps.py b/tests/layer_tests/tensorflow_tests/test_tf_BinaryOps.py index 066470e31fe61c..5c2f122a1602a4 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_BinaryOps.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_BinaryOps.py @@ -112,7 +112,7 @@ def test_binary_op(self, x_shape, y_shape, ie_device, precision, ir_version, tem pytest.skip("Bitwise and Xdivy ops are supported only by new TF FE.") if op_type in ['BitwiseAnd', 'BitwiseOr', 'BitwiseXor', 'Pow', 'Mod'] and ie_device == 'GPU': pytest.skip("GPU does not support Bitwise ops. For Mod and Pow it has inference mismatch") - if op_type in ['Mod', 'FloorDiv']: + if op_type in ['Mod', 'FloorDiv', 'FloorMod']: pytest.skip("Inference mismatch for Mod and FloorDiv") self._test(*self.create_add_placeholder_const_net(x_shape=x_shape, y_shape=y_shape, op_type=op_type), ie_device, precision, ir_version, temp_dir=temp_dir, use_legacy_frontend=use_legacy_frontend) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py index 0976b221e94d21..bd1422f8719cea 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py @@ -75,6 +75,10 @@ def create_lookup_table_find_net(self, hash_table_type, keys_shape, keys_type, v all_keys=['PyTorch', 'TensorFlow', 'JAX', 'Lightning', 'MindSpore', 'OpenVINO'], all_values=[200, 100, 0, -3, 10, 1], default_value=0, invalid_key='AbraCadabra'), + dict(keys_type=str, values_type=np.int32, + all_keys=['First sentence', 'Second one', '', 'Third', 'Fourth Sentence', 'etc.'], + all_values=[-1, 2, 0, -3, 0, 1], + default_value=100, invalid_key='AbraCadabra'), ] @pytest.mark.parametrize("hash_table_type", [0, 1]) @@ -87,7 +91,7 @@ def test_lookup_table_find(self, hash_table_type, keys_shape, params, ie_device, if ie_device == 'GPU' or run_in_jenkins(): pytest.skip("operation extesion is not supported on GPU or " "No layout format available for gather:LookupTableFind issue") - if params['keys_type'] == str and params['values_type'] == np.int64: + if params['keys_type'] == str: if platform.system() in ('Darwin') or platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64',