diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 2b51b6f1f87251..4050f54f867969 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -523,9 +523,7 @@ int main(int argc, char* argv[]) { } } auto result = std::find_if(config.begin(), config.end(), [&](const std::pair& item) { - if (device_name.find(item.first) == 0) - return true; - return false; + return device_name.find(item.first) == 0; }); ov::AnyMap device_config = {}; if (result != config.end()) @@ -548,6 +546,11 @@ int main(int argc, char* argv[]) { } bool isDynamicNetwork = false; + auto areNetworkInputsDynamic = [](const benchmark_app::InputsInfo& input_info) { + return std::any_of(input_info.begin(), input_info.end(), [](const auto& info) { + return info.second.partialShape.is_dynamic(); + }); + }; if (FLAGS_load_from_file && !isNetworkCompiled) { if (!FLAGS_mean_values.empty() || !FLAGS_scale_values.empty()) { @@ -722,12 +725,7 @@ int main(int argc, char* argv[]) { model = preproc.build(); // Check if network has dynamic shapes - auto input_info = app_inputs_info[0]; - isDynamicNetwork = std::any_of(input_info.begin(), - input_info.end(), - [](const std::pair& i) { - return i.second.partialShape.is_dynamic(); - }); + isDynamicNetwork = areNetworkInputsDynamic(app_inputs_info.at(0)); topology_name = model->get_friendly_name(); @@ -789,6 +787,7 @@ int main(int argc, char* argv[]) { FLAGS_scale_values, FLAGS_mean_values, compiledModel.inputs()); + isDynamicNetwork = areNetworkInputsDynamic(app_inputs_info.at(0)); batchSize = get_batch_size(app_inputs_info.at(0)); warn_if_no_batch(app_inputs_info.at(0)); diff --git a/src/frontends/pytorch/src/op/index_put_.cpp b/src/frontends/pytorch/src/op/index_put_.cpp index 1b5725a8a95bb3..4591862d8f04c1 100644 --- a/src/frontends/pytorch/src/op/index_put_.cpp +++ b/src/frontends/pytorch/src/op/index_put_.cpp @@ -10,7 +10,7 @@ namespace frontend { namespace pytorch { namespace op { -OutputVector translate_index_put_(const NodeContext& context) { +OutputVector translate_index_put(const NodeContext& context) { // Pass as PtFrameworkNode to register as `inplace_op`. Conversion to OV operators is done as transformation. auto node = std::make_shared(context.get_decoder(), context.inputs()); return {context.mark_node(node)}; diff --git a/src/frontends/pytorch/src/op/log.cpp b/src/frontends/pytorch/src/op/log.cpp index e932538c86520e..dbda6329deeb4f 100644 --- a/src/frontends/pytorch/src/op/log.cpp +++ b/src/frontends/pytorch/src/op/log.cpp @@ -77,7 +77,7 @@ OutputVector translate_log10(const NodeContext& context) { }; OutputVector translate_logsumexp(const NodeContext& context) { - num_inputs_check(context, 1, 2); + num_inputs_check(context, 1, 3); auto input = context.get_input(0); ov::Output dim; if (!context.input_is_none(1)) { @@ -85,8 +85,12 @@ OutputVector translate_logsumexp(const NodeContext& context) { } else { dim = context.mark_node(get_axes_range(context, 0)); } + bool keepdim = false; + if (!context.input_is_none(2)) { + keepdim = context.const_input(2); + } auto exp = context.mark_node(std::make_shared(input)); - auto sum = context.mark_node(std::make_shared(exp, dim, false)); + auto sum = context.mark_node(std::make_shared(exp, dim, keepdim)); auto log = context.mark_node(std::make_shared(sum)); return {log}; }; diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp index e3fc351cbfc5b2..79b34e8308619a 100644 --- a/src/frontends/pytorch/src/op_table.cpp +++ b/src/frontends/pytorch/src/op_table.cpp @@ -116,7 +116,7 @@ OP_CONVERTER(translate_index); OP_CONVERTER(translate_index_add); OP_CONVERTER(translate_index_copy_); OP_CONVERTER(translate_index_fill_); -OP_CONVERTER(translate_index_put_); +OP_CONVERTER(translate_index_put); OP_CONVERTER(translate_index_select); OP_CONVERTER(translate_instance_norm); OP_CONVERTER(translate_int); @@ -433,6 +433,7 @@ const std::unordered_map get_supported_ops_ts() { {"aten::col2im", op::translate_col2im}, {"aten::complex", op::translate_complex}, {"aten::concat", op::translate_cat}, + {"aten::concatenate", op::translate_cat}, {"aten::contiguous", op::skip_node}, // In openvino how tensors are stored in memory is internal plugin detail, // we assume all tensors are contiguous {"aten::conv_transpose1d", op::translate_conv_transposend}, @@ -465,6 +466,7 @@ const std::unordered_map get_supported_ops_ts() { {"aten::empty", op::translate_empty}, {"aten::empty_like", op::translate_empty_like}, {"aten::eq", op::translate_1to1_match_2_inputs_align_types}, + {"aten::equal", op::translate_1to1_match_2_inputs_align_types}, {"aten::erf", op::translate_erf}, {"aten::erfc", op::translate_erfc}, {"aten::exp", op::optional_out, 1>}, @@ -508,7 +510,7 @@ const std::unordered_map get_supported_ops_ts() { // aten::index - Supported in limited set of patterns {"aten::index_copy_", op::inplace_op}, {"aten::index_fill_", op::inplace_op}, - {"aten::index_put_", op::inplace_op}, + {"aten::index_put", op::translate_index_put}, {"aten::index_add", op::translate_index_add}, {"aten::index_select", op::translate_index_select}, {"aten::instance_norm", op::translate_instance_norm}, @@ -552,6 +554,7 @@ const std::unordered_map get_supported_ops_ts() { {"aten::log2_", op::inplace_op}, {"aten::log10", op::optional_out}, {"aten::log10_", op::inplace_op}, + {"aten::logsumexp", op::translate_logsumexp}, {"aten::lstm", op::translate_lstm}, {"aten::lt", op::translate_1to1_match_2_inputs_align_types}, {"aten::masked_fill", op::translate_masked_fill}, @@ -716,6 +719,7 @@ const std::unordered_map get_supported_ops_ts() { {"ov_ext::embedding", op::translate_embedding_ext}, {"ov_ext::conv1d", op::translate_conv1d_ext}, {"ov_ext::linear", op::translate_linear}, + {"prim::abs", op::translate_1to1_match_1_inputs}, {"prim::Constant", op::translate_constant}, {"prim::device", op::translate_constant}, // prim::DictConstruct - Supported in limited set of patterns diff --git a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp index 008e2bdd6d39de..b7049f62af6d31 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp @@ -54,9 +54,8 @@ void check_level_zero_attributes_match(const IODescriptor& ioDescriptor, const A '\n' + "Given: " + std::to_string(ovDimensions.size())); for (size_t index = 0; index < ovDimensions.size(); ++index) { - OPENVINO_ASSERT( - ioDescriptor.shapeFromCompiler.is_dynamic() || ovDimensions[index] == zeDescriptor.info.dims[index], - "Shape mismatch for input/output named " + ioDescriptor.nameFromCompiler); + OPENVINO_ASSERT(ovDimensions[index] == zeDescriptor.info.dims[index], + "Shape mismatch for input/output named " + ioDescriptor.nameFromCompiler); } for (size_t index = ovDimensions.size(); index < ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE; ++index) { OPENVINO_ASSERT(zeDescriptor.info.dims[index] == 0 || zeDescriptor.info.dims[index] == 1, diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index 2f6eded512ab8e..a3626a79475dcd 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -12,7 +12,9 @@ #include "intel_npu/utils/zero/zero_api.hpp" #include "intel_npu/utils/zero/zero_result.hpp" #include "intel_npu/utils/zero/zero_wrappers.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/model.hpp" +#include "openvino/core/partial_shape.hpp" #define NotSupportQuery(T) (T <= ZE_GRAPH_EXT_VERSION_1_2) @@ -400,7 +402,8 @@ ze_graph_handle_t ZeGraphExtWrappers::getGraphHandle(const std::vector& static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg, const std::optional& metadata) { ov::element::Type_t precision = toOVElementType(arg.devicePrecision); - ov::Shape shapeFromCompiler, shapeFromIRModel; + ov::Shape shapeFromCompiler; + ov::PartialShape shapeFromIRModel; std::unordered_set outputTensorNames; for (uint32_t id = 0; id < arg.associated_tensor_names_count; id++) { @@ -410,8 +413,17 @@ static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg, shapeFromCompiler.push_back(arg.dims[id]); } if (metadata.has_value()) { + const auto dynamicDim = std::numeric_limits::max(); + shapeFromIRModel.reserve(metadata->shape_size); for (uint32_t id = 0; id < metadata->shape_size; id++) { - shapeFromIRModel.push_back(metadata->shape[id]); + if (metadata->shape[id] != dynamicDim) { + shapeFromIRModel.push_back(metadata->shape[id]); + } else { + // lower bound is ignored, so we set it to 1 just to satisfy the Dimension constructor, + // upper bound is set to the value from shapeFromCompiler as it is filled with upper bounds + // in case of dynamic dimensions + shapeFromIRModel.push_back(ov::Dimension(1, shapeFromCompiler[id])); + } } } @@ -433,7 +445,7 @@ static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg, return {std::move(nameFromCompiler), precision, - std::move(shapeFromCompiler), + shapeFromCompiler, isStateInput, isStateOutput, isShapeTensor, diff --git a/src/plugins/intel_npu/tools/single-image-test/main.cpp b/src/plugins/intel_npu/tools/single-image-test/main.cpp index 699e252eacf181..3188075fc58148 100644 --- a/src/plugins/intel_npu/tools/single-image-test/main.cpp +++ b/src/plugins/intel_npu/tools/single-image-test/main.cpp @@ -1569,8 +1569,8 @@ std::pair runInfer(ov::InferRequest& inferRequest, ov::Compi TensorMap out; for (const auto& outputInfo : compiledModel.outputs()) { - const std::string layer_name = outputInfo.get_any_name(); - out.insert({layer_name, inferRequest.get_tensor(layer_name)}); + const std::string layerName = outputInfo.get_any_name(); + out.insert({layerName, inferRequest.get_tensor(layerName)}); } ProfVec profData{}; @@ -1807,11 +1807,17 @@ bool testMeanIoU(const TensorMap& outputs, const TensorMap& references, const La } static ov::Shape parseDataShape(const std::string& dataShapeStr) { - std::vector dataShape; - std::istringstream ss(dataShapeStr); - std::string token; - while (std::getline(ss, token, ',')) { - dataShape.push_back(std::stoul(token)); + std::vector dataShape; + std::stringstream ss(dataShapeStr); + + char ch; // To discard non-numeric characters + int64_t dim; + while (ss >> ch) { + if (std::isdigit(ch)) { + ss.putback(ch); + ss >> dim; + dataShape.push_back(dim); + } } return ov::Shape(dataShape); } @@ -1906,11 +1912,11 @@ static int runSingleImageTest() { auto model = core.read_model(FLAGS_network); nameIOTensors(model); - auto inputs_info = std::const_pointer_cast(model)->inputs(); - InputsInfo info_map; + auto inputsInfo = std::const_pointer_cast(model)->inputs(); + InputsInfo infoMap; std::cout << "Performing reshape" << std::endl; - reshape(std::move(inputs_info), info_map, model, FLAGS_shape, + reshape(std::move(inputsInfo), infoMap, model, FLAGS_shape, FLAGS_override_model_batch_size, FLAGS_device); ov::preprocess::PrePostProcessor ppp(model); diff --git a/tests/layer_tests/pytorch_tests/test_logsumexp.py b/tests/layer_tests/pytorch_tests/test_logsumexp.py new file mode 100644 index 00000000000000..806e3b80540d5a --- /dev/null +++ b/tests/layer_tests/pytorch_tests/test_logsumexp.py @@ -0,0 +1,34 @@ +# Copyright (C) 2018-2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +import torch + +from pytorch_layer_test_class import PytorchLayerTest + + +class aten_logsumexp(torch.nn.Module): + def __init__(self, dim, keepdim) -> None: + super().__init__() + self.dim = dim + self.keepdim = keepdim + + def forward(self, input_tensor): + return torch.logsumexp(input_tensor, dim=self.dim, keepdim=self.keepdim) + + +class TestLogsumexp(PytorchLayerTest): + def _prepare_input(self): + return (np.random.randn(2, 5, 9, 7),) + + @pytest.mark.parametrize("dim", [ + 0, 1, 2, 3, -1, -2, -3, -4 + ]) + @pytest.mark.parametrize("keepdim", [True, False]) + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.precommit_fx_backend + def test_logsumexp(self, dim, keepdim, ie_device, precision, ir_version): + self._test(aten_logsumexp(dim, keepdim), None, "aten::logsumexp", + ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_unary_ops.py b/tests/layer_tests/pytorch_tests/test_unary_ops.py index 9807343080043c..584a80fe4ce254 100644 --- a/tests/layer_tests/pytorch_tests/test_unary_ops.py +++ b/tests/layer_tests/pytorch_tests/test_unary_ops.py @@ -75,7 +75,7 @@ class unary_op_net(torch.nn.Module): def __init__(self, op, dtype): - super(unary_op_net, self).__init__() + super().__init__() self.dtype = dtype self.op = op @@ -87,7 +87,7 @@ def forward(self, x): class unary_op_out_net(torch.nn.Module): def __init__(self, op, dtype): - super(unary_op_out_net, self).__init__() + super().__init__() self.dtype = dtype self.op = op @@ -101,7 +101,7 @@ def forward(self, x): class unary_func_op_inplace_net(torch.nn.Module): def __init__(self, op, dtype): - super(unary_func_op_inplace_net, self).__init__() + super().__init__() self.dtype = dtype self.op = op @@ -111,6 +111,17 @@ def forward(self, x): return y, x1 +class prim_abs_net(torch.nn.Module): + def __init__(self, dtype): + super().__init__() + self.dtype = dtype + + def forward(self, x): + x1 = x.to(self.dtype) + y = abs(x1) + return y, x1 + + class TestUnaryOp(PytorchLayerTest): def _prepare_input(self): # random number in range [1, 11) @@ -265,3 +276,13 @@ def test_unary_func_op_inplace(self, op_type, dtype, ie_device, precision, ir_ve self.dtype = dtype self._test(unary_func_op_inplace_net(OPS[op_type], dtype), None, op_type + "_", ie_device, precision, ir_version) + + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.precommit_torch_export + @pytest.mark.precommit_fx_backend + @pytest.mark.parametrize("dtype", [torch.float32, torch.float64, torch.int8, torch.uint8, torch.int32, torch.int64]) + def test_prim_abs(self, dtype, ie_device, precision, ir_version): + self.dtype = dtype + self._test(prim_abs_net(dtype), None, "prim::abs", + ie_device, precision, ir_version) diff --git a/tools/constraints.txt b/tools/constraints.txt deleted file mode 100644 index 73d244545aa499..00000000000000 --- a/tools/constraints.txt +++ /dev/null @@ -1,16 +0,0 @@ -# EXCEPTIONS -# some package versions need to be specified in respective requirements.txt -# files because the version differs between them: -# tensorflow, numpy -h5py>=3.1.0,<3.11.0 -onnx>=1.8.1,<=1.17.0 -pytest>=5.0,<8.4 -protobuf>=3.18.1,<4.0.0 -defusedxml>=0.7.1 -requests>=2.25.1 -coverage>=4.4.2,<=7.0.5 -astroid>=2.9.0 -pylint>=2.7.0 -pyenchant>=3.0.0 -urllib3>=1.26.4 -openvino-telemetry>=2023.2.1