Throw an exceptions in case of incorrect pointers in Model creation (#15492)
This commit is contained in:
parent
52eefb8fb0
commit
b5fea2a5fd
@ -186,6 +186,22 @@ ov::Model::Model(const OutputVector& results, const string& name) : Model(result
|
|||||||
void ov::Model::prerequirements(bool detect_variables, bool detect_parameters) {
|
void ov::Model::prerequirements(bool detect_variables, bool detect_parameters) {
|
||||||
OV_ITT_SCOPED_TASK(ov::itt::domains::core, "Model::prerequirements");
|
OV_ITT_SCOPED_TASK(ov::itt::domains::core, "Model::prerequirements");
|
||||||
|
|
||||||
|
for (const auto& param : m_parameters) {
|
||||||
|
OPENVINO_ASSERT(param != nullptr, "Model is incorrect! Some Parameter operation equals to nullptr.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& result : m_results) {
|
||||||
|
OPENVINO_ASSERT(result != nullptr, "Model is incorrect! Some Result operation equals to nullptr.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& sink : m_sinks) {
|
||||||
|
OPENVINO_ASSERT(sink != nullptr, "Model is incorrect! Some Sink operation equals to nullptr.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& variable : m_variables) {
|
||||||
|
OPENVINO_ASSERT(variable != nullptr, "Model is incorrect! Some Variable equals to nullptr.");
|
||||||
|
}
|
||||||
|
|
||||||
m_shared_rt_info = std::make_shared<SharedRTInfo>();
|
m_shared_rt_info = std::make_shared<SharedRTInfo>();
|
||||||
|
|
||||||
const auto& ordered_ops = get_ordered_ops();
|
const auto& ordered_ops = get_ordered_ops();
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include "openvino/core/node.hpp"
|
#include "openvino/core/node.hpp"
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
Input<Node>::Input(Node* node, size_t index) : m_node(node), m_index(index) {}
|
Input<Node>::Input(Node* node, size_t index) : m_node(node), m_index(index) {
|
||||||
|
OPENVINO_ASSERT(m_node, "Cannot create ov::Input<ov::Node> from nullptr!");
|
||||||
|
}
|
||||||
|
|
||||||
Node* Input<Node>::get_node() const {
|
Node* Input<Node>::get_node() const {
|
||||||
return m_node;
|
return m_node;
|
||||||
@ -72,7 +74,9 @@ bool Input<Node>::operator<=(const Input& other) const {
|
|||||||
bool Input<Node>::operator>=(const Input& other) const {
|
bool Input<Node>::operator>=(const Input& other) const {
|
||||||
return !(*this < other);
|
return !(*this < other);
|
||||||
}
|
}
|
||||||
Input<const Node>::Input(const Node* node, size_t index) : m_node(node), m_index(index) {}
|
Input<const Node>::Input(const Node* node, size_t index) : m_node(node), m_index(index) {
|
||||||
|
OPENVINO_ASSERT(m_node, "Cannot create ov::Input<const ov::Node> from nullptr!");
|
||||||
|
}
|
||||||
|
|
||||||
RTMap& Input<Node>::get_rt_info() {
|
RTMap& Input<Node>::get_rt_info() {
|
||||||
return m_node->m_inputs.at(m_index).get_rt_info();
|
return m_node->m_inputs.at(m_index).get_rt_info();
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
#include "openvino/op/parameter.hpp"
|
#include "openvino/op/parameter.hpp"
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
Output<Node>::Output(Node* node, size_t index) : m_node(node->shared_from_this()), m_index(index) {}
|
Output<Node>::Output(Node* node, size_t index) : m_index(index) {
|
||||||
|
OPENVINO_ASSERT(node, "Cannot create ov::Output<ov::Node> from nullptr!");
|
||||||
|
m_node = node->shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
Output<Node>::Output(const std::shared_ptr<Node>& node, size_t index) : m_node(node), m_index(index) {}
|
Output<Node>::Output(const std::shared_ptr<Node>& node, size_t index) : m_node(node), m_index(index) {}
|
||||||
|
|
||||||
@ -144,7 +147,11 @@ bool Output<Node>::operator<=(const Output& other) const {
|
|||||||
bool Output<Node>::operator>=(const Output& other) const {
|
bool Output<Node>::operator>=(const Output& other) const {
|
||||||
return !(*this < other);
|
return !(*this < other);
|
||||||
}
|
}
|
||||||
Output<const Node>::Output(const Node* node, size_t index) : m_node(node->shared_from_this()), m_index(index) {}
|
|
||||||
|
Output<const Node>::Output(const Node* node, size_t index) : m_index(index) {
|
||||||
|
OPENVINO_ASSERT(node, "Cannot create ov::Output<const ov::Node> from nullptr!");
|
||||||
|
m_node = node->shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
Output<const Node>::Output(const std::shared_ptr<const Node>& node, size_t index) : m_node(node), m_index(index) {}
|
Output<const Node>::Output(const std::shared_ptr<const Node>& node, size_t index) : m_node(node), m_index(index) {}
|
||||||
|
|
||||||
|
@ -2040,3 +2040,15 @@ TEST(model, set_complex_meta_information) {
|
|||||||
|
|
||||||
check_rt_info(f);
|
check_rt_info(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(model, create_model) {
|
||||||
|
EXPECT_NO_THROW(ov::Model({}, ""));
|
||||||
|
EXPECT_THROW(ov::Model(ov::ResultVector{nullptr}, {}, ""), ov::Exception);
|
||||||
|
EXPECT_NO_THROW(ov::Model(ov::ResultVector{}, ov::ParameterVector{}, ""));
|
||||||
|
EXPECT_THROW(ov::Model({nullptr}, {nullptr}, {nullptr}, {nullptr}, ""), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Model({nullptr}, {}, {}, {}, ""), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Model(ov::ResultVector{}, {nullptr}, {}, {}, ""), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Model(ov::ResultVector{}, {}, {nullptr}, {}, ""), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Model(ov::ResultVector{}, {}, {}, {nullptr}, ""), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Model(ov::OutputVector{ov::Output<ov::Node>{nullptr, 0}}, {}, {}, {}, ""), ov::Exception);
|
||||||
|
}
|
||||||
|
@ -143,3 +143,10 @@ TEST(node_input_output, input_set_argument) {
|
|||||||
EXPECT_EQ(add->input(0).get_shape(), Shape{3});
|
EXPECT_EQ(add->input(0).get_shape(), Shape{3});
|
||||||
EXPECT_EQ(add->input(1).get_shape(), Shape{1});
|
EXPECT_EQ(add->input(1).get_shape(), Shape{1});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(node_input_output, create_wrong_input_output) {
|
||||||
|
EXPECT_THROW(ov::Output<ov::Node>(nullptr, 0), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Output<const ov::Node>(nullptr, 0), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Input<ov::Node>(nullptr, 0), ov::Exception);
|
||||||
|
EXPECT_THROW(ov::Input<const ov::Node>(nullptr, 0), ov::Exception);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user