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
[PT FE] Handle None-value case among inputs (#27102)
Roman Kazantsev28bb0fd51003
diff --git a/src/frontends/pytorch/src/node_context.cpp b/src/frontends/pytorch/src/node_context.cppindex 565b0cdbd39..6a8c370ef2b 100644--- a/src/frontends/pytorch/src/node_context.cpp+++ b/src/frontends/pytorch/src/node_context.cpp@@ -4,6 +4,7 @@#include "openvino/frontend/pytorch/node_context.hpp"+#include "helper_ops/internal_op.hpp"#include "openvino/core/validation_util.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/frontend/pytorch/decoder.hpp"@@ -151,13 +152,26 @@ OutputVector NodeContext::inputs() const {if (input == 0) {// Case when input can be inlined (possible only for fx decoder)if (m_decoder->is_input_inlined(i)) {- auto inlined_input = m_decoder->inlined_input(i);- FRONT_END_GENERAL_CHECK(inlined_input.size() == 1,- "Incorrect inlined input with index: ",- i,- " for operation ",- get_op_type());- res.push_back(inlined_input[0]);+ if (input_is_none(i)) {+ // some operations like aten.index.Tensor can have None inputs+ auto dummy_decoder = std::make_shared<InternalOpDecoder>("torch::None", 1);+ auto fw_node = std::make_shared<PtFrameworkNode>(dummy_decoder, OutputVector{});+ auto attrs = fw_node->get_attrs();+ attrs["none_value"] = "";+ attrs[PtFrameworkNode::failed_conversion_key] =+ "None constant cannot be converted to OpenVINO opset and should be removed by consuming "+ "operation.";+ fw_node->set_attrs(attrs);+ res.push_back(fw_node->output(0));+ } else {+ auto inlined_input = m_decoder->inlined_input(i);+ FRONT_END_GENERAL_CHECK(inlined_input.size() == 1,+ "Incorrect inlined input with index: ",+ i,+ " for operation ",+ get_op_type());+ res.push_back(inlined_input[0]);+ }continue;}}