[CPU] Nodes errors handling moved to graph (#24161)

### Details:
 - *item1*
 - *...*

### Tickets:
 - *136887*
This commit is contained in:
Yury Gaydaychuk 2024-05-30 11:23:05 +02:00 committed by GitHub
parent 48f64b6086
commit 522a3c6a7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 55 additions and 35 deletions

View File

@ -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());
}
}
}
}

View File

@ -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<VectorDims> Node::shapeInferGeneric(const std::vector<Shape>& 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<std::reference_wrapper<const VectorDims>> input_shapes;
auto input_value_port_mask = shapeInference->get_port_mask();
std::vector<std::reference_wrapper<const VectorDims>> 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<size_t, MemoryPtr> 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<size_t, MemoryPtr> 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

View File

@ -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 <class... T>
constexpr uint64_t PortMask(T... rest) {
return util::bit::mask(rest...);