diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp index b3f23d2c6cc..f1764dc174d 100644 --- a/src/plugins/intel_cpu/src/graph.cpp +++ b/src/plugins/intel_cpu/src/graph.cpp @@ -1359,7 +1359,11 @@ void Graph::InferDynamic(SyncInferRequest* request) { if (request) request->throw_if_canceled(); - ExecuteNode(node, stream); + try { + ExecuteNode(node, stream); + } catch (const std::exception& exp) { + OPENVINO_THROW(node, exp.what()); + } } } } diff --git a/src/plugins/intel_cpu/src/node.cpp b/src/plugins/intel_cpu/src/node.cpp index bd2f52adf04..1305895ed37 100644 --- a/src/plugins/intel_cpu/src/node.cpp +++ b/src/plugins/intel_cpu/src/node.cpp @@ -548,12 +548,16 @@ void Node::updateShapes() { getTypeStr(), " with name: ", getName()); - if (needShapeInfer()) { - auto result = shapeInfer(); - if (ShapeInferStatus::success == result.status) { - redefineOutputMemory(result.dims); + try { + if (needShapeInfer()) { + auto result = shapeInfer(); + if (ShapeInferStatus::success == result.status) { + redefineOutputMemory(result.dims); + } + } + } catch (const std::exception& exp) { + THROW_CPU_NODE_ERR(exp.what()); } - } } void Node::updateDynamicParams() { @@ -562,18 +566,18 @@ void Node::updateDynamicParams() { getTypeStr(), " with name: ", getName()); - if (isExecutable()) { - if (needPrepareParams()) { - OPENVINO_ASSERT(inputShapesDefined(), - "Can't prepare params for ", - getTypeStr(), - " node with name: ", - getName(), - " since the input shapes are not defined."); - DEBUG_LOG(" prepareParams() on #", getExecIndex(), " ", getTypeStr(), " ", algToString(getAlgorithm()), - " ", getName(), " ", getOriginalLayers()); - prepareParams(); + try { + if (isExecutable()) { + if (needPrepareParams()) { + OPENVINO_ASSERT(inputShapesDefined(), + "Input shapes are not defined."); + DEBUG_LOG(" prepareParams() on #", getExecIndex(), " ", getTypeStr(), " ", algToString(getAlgorithm()), + " ", getName(), " ", getOriginalLayers()); + prepareParams(); + } } + } catch (const std::exception& e) { + THROW_CPU_NODE_ERR(e.what()); } } @@ -1597,34 +1601,29 @@ std::vector Node::shapeInferGeneric(const std::vector& shapes } return std::move(result.dims); - } catch (const std::runtime_error& exp) { + } catch (const std::exception& exp) { OPENVINO_THROW("Shape inference of ", getTypeStr(), " node with name ", getName(), " failed: ", exp.what()); } } IShapeInfer::Result Node::shapeInfer() const { - try { - std::vector> input_shapes; - auto input_value_port_mask = shapeInference->get_port_mask(); + std::vector> input_shapes; + auto input_value_port_mask = shapeInference->get_port_mask(); - input_shapes.reserve(inputShapes.size()); - for (size_t port = 0; port < inputShapes.size(); ++port) - input_shapes.emplace_back(std::ref(getParentEdgeAt(port)->getMemory().getStaticDims())); + input_shapes.reserve(inputShapes.size()); + for (size_t port = 0; port < inputShapes.size(); ++port) + input_shapes.emplace_back(std::ref(getParentEdgeAt(port)->getMemory().getStaticDims())); - std::unordered_map input_values; - if (input_value_port_mask) { - for (size_t port = 0; port < inputShapes.size(); ++port) { - if (input_value_port_mask & (1 << port)) { - input_values[port] = getSrcMemoryAtPort(port); - } + std::unordered_map input_values; + if (input_value_port_mask) { + for (size_t port = 0; port < inputShapes.size(); ++port) { + if (input_value_port_mask & (1 << port)) { + input_values[port] = getSrcMemoryAtPort(port); } } + } - return shapeInference->infer(input_shapes, input_values); - } - catch (const std::runtime_error& exp) { - OPENVINO_THROW("Shape inference of ", getTypeStr() , " node with name ", getName(), " failed: ", exp.what()); - } + return shapeInference->infer(input_shapes, input_values); } void Node::updateLastInputDims() { @@ -1942,5 +1941,16 @@ void Node::resolveInPlaceDirection() { } } +#ifndef CPU_DEBUG_CAPS +std::ostream& operator<<(std::ostream& out, const Node& node) { + return out << "Node " << node.getName() << + " of type " << node.getTypeStr() << "\n"; +} + +std::ostream& operator<<(std::ostream& out, const Node* node) { + return operator<<(out, (*node)); +} +#endif + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/node.h b/src/plugins/intel_cpu/src/node.h index f92ec31a0b1..d442c0280ab 100644 --- a/src/plugins/intel_cpu/src/node.h +++ b/src/plugins/intel_cpu/src/node.h @@ -833,6 +833,12 @@ private: CPU_DEBUG_CAP_ENABLE(friend class Verbose); }; +#ifndef CPU_DEBUG_CAPS +std::ostream& operator<<(std::ostream&, const Node&); + +std::ostream& operator<<(std::ostream&, const Node*); +#endif + template constexpr uint64_t PortMask(T... rest) { return util::bit::mask(rest...);