Remove constructors for ov Exceptions (#16938)

* Remove constructors for ov Exceptions

* Fixed linux build

* Fixed ONNX Frontend

* Fixed paddle

* Fixed exceptions in tests

* Deprecate constructors for ov::Exception

* Suppress some warnings

* Merge several exceptions

* Some small changes

* Suppress more warnings

* More warnings

* mode warnings

* Suppress more warnings

* More warnings
This commit is contained in:
Ilya Churaev
2023-04-18 21:02:26 +04:00
committed by GitHub
parent 441dad2eea
commit 566ef01a3f
251 changed files with 834 additions and 649 deletions
+6 -7
View File
@@ -863,10 +863,9 @@ int main(int argc, char* argv[]) {
try {
nireq = compiledModel.get_property(ov::optimal_number_of_infer_requests);
} catch (const std::exception& ex) {
throw ov::Exception("Every device used with the benchmark_app should support " +
std::string(ov::optimal_number_of_infer_requests.name()) +
" Failed to query the metric for the " + device_name +
" with error: " + ex.what());
OPENVINO_THROW("Every device used with the benchmark_app should support " +
std::string(ov::optimal_number_of_infer_requests.name()) +
" Failed to query the metric for the " + device_name + " with error: " + ex.what());
}
}
}
@@ -964,7 +963,7 @@ int main(int argc, char* argv[]) {
nireq);
}
} else {
throw ov::Exception("Requested device doesn't support `use_device_mem` option.");
OPENVINO_THROW("Requested device doesn't support `use_device_mem` option.");
}
} else {
if (newInputType) {
@@ -1056,7 +1055,7 @@ int main(int argc, char* argv[]) {
// warming up - out of scope
auto inferRequest = inferRequestsQueue.get_idle_request();
if (!inferRequest) {
throw ov::Exception("No idle Infer Requests!");
OPENVINO_THROW("No idle Infer Requests!");
}
if (!inferenceOnly) {
@@ -1107,7 +1106,7 @@ int main(int argc, char* argv[]) {
(FLAGS_api == "async" && iteration % nireq != 0)) {
inferRequest = inferRequestsQueue.get_idle_request();
if (!inferRequest) {
throw ov::Exception("No idle Infer Requests!");
OPENVINO_THROW("No idle Infer Requests!");
}
if (!inferenceOnly) {
@@ -494,7 +494,7 @@ static inline void fill_tensor_random(ov::Tensor tensor) {
fill_random<uint8_t, uint32_t>(tensor, 0, 1);
break;
default:
throw ov::Exception("Input type is not supported for a tensor");
OPENVINO_THROW("Input type is not supported for a tensor");
}
}
@@ -77,7 +77,7 @@ private:
auto it = s_opsets.find(opset_ver);
if (it == s_opsets.end()) {
throw ngraph::ngraph_error("Unsupported opset version requested.");
OPENVINO_THROW("Unsupported opset version requested.");
}
return it->second();
}
@@ -67,7 +67,7 @@ const TensorIndexMap cast_to_tensor_index_map(const py::dict& inputs) {
auto tensor = Common::cast_to_tensor(input.second);
result_map[idx] = tensor;
} else {
throw ov::Exception("Unable to cast tensor " + std::to_string(idx) + "!");
OPENVINO_THROW("Unable to cast tensor " + std::to_string(idx) + "!");
}
}
return result_map;
@@ -186,7 +186,7 @@ py::array array_from_tensor(ov::Tensor&& t) {
break;
}
default: {
throw ov::Exception("Numpy array cannot be created from given OV Tensor!");
OPENVINO_THROW("Numpy array cannot be created from given OV Tensor!");
break;
}
}
@@ -33,7 +33,7 @@ OV_CC_DOMAINS(ov_pass);
# define MATCHER_SCOPE_(scope, region) \
if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(scope, _, region)) == 0) \
throw ngraph::ngraph_error(std::string(OV_PP_TOSTRING(OV_PP_CAT3(scope, _, region))) + " is disabled!")
OPENVINO_THROW(std::string(OV_PP_TOSTRING(OV_PP_CAT3(scope, _, region))) + " is disabled!")
# define MATCHER_SCOPE(region) \
const std::string matcher_name(OV_PP_TOSTRING(region)); \
@@ -715,7 +715,7 @@ public:
for (auto node : fq_params_nodes) {
auto const_node = std::dynamic_pointer_cast<op::Constant>(node);
if (!const_node)
throw ngraph_error("Unexpected operation type.");
OPENVINO_THROW("Unexpected operation type.");
auto new_shape = broadcast_shape_to_rank(const_node->get_shape(),
m_input.get_partial_shape().rank().get_length());
auto new_const = std::make_shared<op::Constant>(*const_node, new_shape);
@@ -273,8 +273,8 @@ bool ngraph::pass::ShrinkWeights::run_on_model(const std::shared_ptr<ngraph::Fun
// TODO: think about it
auto res = const_node->get_shape_val();
if (res.size() != mask->size()) {
throw ngraph_error("Mask size (" + std::to_string(mask->size()) + ") is not equal to (" +
std::to_string(res.size()) + ")");
OPENVINO_THROW("Mask size (" + std::to_string(mask->size()) + ") is not equal to (" +
std::to_string(res.size()) + ")");
}
for (size_t dim = 0; dim < mask->size(); ++dim) {
res[dim] -= mask->at(dim).size();
@@ -6,6 +6,7 @@
#include <vector>
#include <cstdint>
#include "ngraph/node.hpp"
namespace ngraph {
namespace snippets {
@@ -50,7 +50,7 @@ public:
std::function<std::shared_ptr<Emitter>(std::shared_ptr<ngraph::Node>)> get(const ngraph::DiscreteTypeInfo type) const {
auto jitter = jitters.find(type);
if (jitter == jitters.end()) {
throw ngraph_error(std::string("Target code emitter is not available for ") + type.name + " operation.");
OPENVINO_THROW(std::string("Target code emitter is not available for ") + type.name + " operation.");
}
return jitter->second.first;
}
@@ -59,7 +59,7 @@ public:
get_supported_precisions(const ngraph::DiscreteTypeInfo type) const {
auto jitter = jitters.find(type);
if (jitter == jitters.end()) {
throw ngraph_error(std::string("Target code emitter is not available for ") + type.name + " operation.");
OPENVINO_THROW(std::string("Target code emitter is not available for ") + type.name + " operation.");
}
return jitter->second.second;
}
+2 -2
View File
@@ -99,7 +99,7 @@ ngraph::snippets::code ngraph::snippets::Generator::generate(std::shared_ptr<ov:
const void* compile_params) {
OV_ITT_SCOPED_TASK(ngraph::pass::itt::domains::SnippetsTransform, "Snippets::Generator::generate")
if (!target->is_supported())
throw ngraph_error("unsupported architecture for code generation");
OPENVINO_THROW("unsupported architecture for code generation");
OV_ITT_TASK_CHAIN(GENERATE, ngraph::pass::itt::domains::SnippetsTransform, "Snippets::Generator", "::VectorTile")
// vector loop
@@ -259,7 +259,7 @@ Generator::opRegType Generator::get_op_reg_type(const std::shared_ptr<Node>& op)
}
Generator::opRegType Generator::get_specific_op_reg_type(const std::shared_ptr<ov::Node>& op) const {
throw ov::Exception("Register type of the operation " + std::string(op->get_type_name()) + " isn't determined!");
OPENVINO_THROW("Register type of the operation " + std::string(op->get_type_name()) + " isn't determined!");
}
+1 -1
View File
@@ -56,7 +56,7 @@ ov::element::Type Brgemm::get_output_type() const {
} else if (is_int8) {
return element::i32;
} else {
throw ngraph_error("BrgemmCPU node has incompatible input element types: " +
OPENVINO_THROW("BrgemmCPU node has incompatible input element types: " +
element_type_a.get_type_name() +
" and " +
element_type_b.get_type_name());
+2 -2
View File
@@ -57,7 +57,7 @@ void snippets::op::Buffer::validate_and_infer_types() {
output_type = get_input_element_type(0);
output_shape = input_shape.get_shape();
} else {
throw ov::Exception("Buffer supports only the following types: NewMemory and IntermediateMemory");
OPENVINO_THROW("Buffer supports only the following types: NewMemory and IntermediateMemory");
}
set_output_type(0, output_type, output_shape);
}
@@ -70,7 +70,7 @@ std::shared_ptr<Node> snippets::op::Buffer::clone_with_new_inputs(const OutputVe
} else if (m_type == Type::IntermediateMemory) {
return std::make_shared<Buffer>(new_args.at(0), m_shape);
}
throw ov::Exception("Buffer supports only the following types: NewMemory and IntermediateMemory");
OPENVINO_THROW("Buffer supports only the following types: NewMemory and IntermediateMemory");
}
size_t ngraph::snippets::op::Buffer::get_byte_size() const {
+4 -4
View File
@@ -184,7 +184,7 @@ auto snippets::op::Subgraph::wrap_node_as_subgraph(const std::shared_ptr<ov::Nod
}
if (node->get_output_size() != body_node->get_output_size()) {
throw ngraph::ngraph_error("original node outputs size and extracted subgraph node outputs size doesn't much");
OPENVINO_THROW("original node outputs size and extracted subgraph node outputs size doesn't much");
}
ngraph::ResultVector body_results;
@@ -212,7 +212,7 @@ auto snippets::op::Subgraph::wrap_node_as_subgraph(const std::shared_ptr<ov::Nod
}
if (subgraph->get_output_size() != body->get_results().size()) {
throw ngraph::ngraph_error("newly create subgraph doesn't much number of original node results");
OPENVINO_THROW("newly create subgraph doesn't much number of original node results");
}
return subgraph;
@@ -446,7 +446,7 @@ void snippets::op::Subgraph::initialize_buffer_scratchpad_size() {
if (auto memory_access = ov::as_type_ptr<ngraph::snippets::op::MemoryAccess>(parent)) {
memory_access->set_output_offset(offset, idx);
} else {
throw ngraph_error(
OPENVINO_THROW(
"Buffer::set_offset() was called when Buffer didn't have the corresponding MemoryAccess op for offset propagation");
}
}
@@ -468,7 +468,7 @@ void snippets::op::Subgraph::initialize_buffer_scratchpad_size() {
} else if (auto memory_access = ov::as_type_ptr<ngraph::snippets::op::MemoryAccess>(child)) {
memory_access->set_input_offset(offset, target_input.get_index());
} else {
throw ngraph_error("Buffer::set_offset() was called when Buffer didn't have the corresponding MemoryAccess op for offset propagation");
OPENVINO_THROW("Buffer::set_offset() was called when Buffer didn't have the corresponding MemoryAccess op for offset propagation");
}
};
@@ -118,7 +118,7 @@ bool ngraph::snippets::pass::AssignRegisters::run_on_model(const std::shared_ptr
std::set<Reg> result;
for (const auto& t : tensors) {
if (reg_map.count(t) == 0)
throw ngraph::ngraph_error("Assign registers: attempt to access not enumerated tensor");
OPENVINO_THROW("Assign registers: attempt to access not enumerated tensor");
Reg reg_id = reg_map.at(t);
if (reg_id != IS_MANUALLY_ALLOCATED_REG)
result.insert(reg_id);
@@ -179,7 +179,7 @@ bool ngraph::snippets::pass::AssignRegisters::run_on_model(const std::shared_ptr
for (const auto& port : out.get_target_inputs()) {
size_t k = std::find(ops.begin(), ops.end(), port.get_node()->shared_from_this()) - ops.begin();
if (k == ops.size())
throw ngraph_error("assign registers can't find target op in the body");
OPENVINO_THROW("assign registers can't find target op in the body");
switch (typed_ops[k].first) {
case opRegType::vec2vec:
case opRegType::vec2gpr:
@@ -258,7 +258,7 @@ bool ngraph::snippets::pass::AssignRegisters::run_on_model(const std::shared_ptr
if (active.size() == reg_pool.size()) {
// todo: if it is LoopBegin or LoopEnd that requires gpr, and we don't have any in the pool,
// then assign SIZE_MAX-1 as a flag to spill a reg inside emitter
throw ngraph::ngraph_error("can't allocate registers for a snippet ");
OPENVINO_THROW("can't allocate registers for a snippet ");
} else {
register_map[unique_reg] = bank.top();
bank.pop();
@@ -287,7 +287,7 @@ bool ngraph::snippets::pass::AssignRegisters::run_on_model(const std::shared_ptr
if (reg.second == IS_MANUALLY_ALLOCATED_REG)
continue;
if (unique2reused.count(reg.second) == 0)
throw ngraph::ngraph_error("Assign registers failed to allocate register for a tensor");
OPENVINO_THROW("Assign registers failed to allocate register for a tensor");
assigned_regs[reg.first] = unique2reused.at(reg.second);
}
};
@@ -506,7 +506,7 @@ TokenizeSnippets::TokenizeSnippets() {
<< " body node outputs = " << body_node->get_output_size() << std::endl;
if (node->get_output_size() != body_node->get_output_size()) {
throw ngraph_error("original node outputs size and extracted node outputs size doesn't much");
OPENVINO_THROW("original node outputs size and extracted node outputs size doesn't much");
}
// After some transformations, a different number of Constants for some operations may be created
@@ -552,7 +552,7 @@ TokenizeSnippets::TokenizeSnippets() {
}
if (!!subgraph_result_inputs.back().count(target_input)) {
throw ngraph_error("target input added twice!!!");
OPENVINO_THROW("target input added twice!!!");
}
// save target input port outside the body
subgraph_result_inputs.back().insert(target_input);
@@ -567,7 +567,7 @@ TokenizeSnippets::TokenizeSnippets() {
}
if (body_results.size() != subgraph_result_inputs.size()) {
throw ngraph_error("body results and node results size mismatch during subgraph collaps");
OPENVINO_THROW("body results and node results size mismatch during subgraph collaps");
}
// todo: move this plugin-specific constraint to the plugin callback
@@ -593,7 +593,7 @@ TokenizeSnippets::TokenizeSnippets() {
}
if (subgraph->get_output_size() != subgraph_result_inputs.size()) {
throw ngraph_error("newly create subgraph doesn't much number of results");
OPENVINO_THROW("newly create subgraph doesn't much number of results");
}
if (outputs_are_not_broadcastable(subgraph))
@@ -37,7 +37,7 @@ ngraph::snippets::pass::InsertBuffer::InsertBuffer(const int32_t allocation_rank
}
if (ov::is_type<op::Buffer>(input.get_source_output().get_node_shared_ptr()) &&
input.get_source_output().get_target_inputs().size() != 1) {
throw ngraph::ngraph_error(
OPENVINO_THROW(
"If Buffer is a input for operation output, this Buffer should be a single consumer for this port");
}
}
@@ -62,7 +62,7 @@ ngraph::snippets::pass::InsertBuffer::InsertBuffer(const int32_t allocation_rank
* / \
* Buffer Result
*/
throw ngraph::ngraph_error(
OPENVINO_THROW(
"Operation which is should be wrapped by Buffers has few children from one output port where one of them is Result");
}
}
@@ -88,7 +88,7 @@ ngraph::snippets::pass::InsertBuffer::InsertBuffer(const int32_t allocation_rank
return ov::is_type<ngraph::snippets::op::Buffer>(child) && child->output(0).get_target_inputs().size() > 0;
});
if (has_buffer_on_output && new_target_inputs.size() != 1) {
throw ngraph::ngraph_error(
OPENVINO_THROW(
"If Buffer is a input for operation output, this Buffer should be a single consumer for this port");
}
}
@@ -17,7 +17,7 @@ namespace pass {
InsertLoops::InsertLoops(ov::PartialShape master_shape, size_t loop_depth, size_t vector_size, bool single_loop_body)
: m_master_shape(std::move(master_shape)), m_loop_depth(loop_depth), m_vector_size(vector_size), m_single_loop_body(single_loop_body) {
if (m_master_shape.size() < m_loop_depth)
throw ngraph_error("InsertLoops can't insert loops: master shape rank is too small");
OPENVINO_THROW("InsertLoops can't insert loops: master shape rank is too small");
}
std::vector<bool> InsertLoops::calculate_inner_apply_increments(const ov::PartialShape& master,
@@ -215,7 +215,7 @@ void insert_loops_explicitly(const ov::NodeVector& ops, const size_t vector_size
bool InsertLoops::run_on_model(const std::shared_ptr<ov::Model> &model) {
RUN_ON_FUNCTION_SCOPE(InsertLoops);
if (m_master_shape.is_dynamic())
throw ngraph_error("InsertLoops doesn't support dynamic shapes yet");
OPENVINO_THROW("InsertLoops doesn't support dynamic shapes yet");
const auto inner_work_amount = utils::get_inner_dim(m_master_shape).get_length();
const auto outer_work_amount = m_loop_depth == 2 ? utils::get_outer_dim(m_master_shape).get_length() : 1;
@@ -231,11 +231,11 @@ bool InsertLoops::run_on_model(const std::shared_ptr<ov::Model> &model) {
const auto& body_rt_info = model->get_rt_info();
const auto& plugin_shapes = body_rt_info.find("PluginShapesOverride");
if (plugin_shapes == body_rt_info.end()) {
throw ngraph_error("InsertLoops requires PluginShapesOverride rt_info field");
OPENVINO_THROW("InsertLoops requires PluginShapesOverride rt_info field");
} else {
const auto& new_shapes = plugin_shapes->second.as<std::vector<std::vector<size_t>>>();
if (new_shapes.size() != commonResults.size() + commonParams.size())
throw ngraph_error("InsertLoops got invalid number of plugin-overriden shapes");
OPENVINO_THROW("InsertLoops got invalid number of plugin-overriden shapes");
for (size_t i = 0; i < commonParams.size(); i++)
ioShapes.emplace_back(new_shapes[i]);
// reverse overriden_shapes for results since commonResults are reversed with respect to model->get_parameters()
@@ -23,7 +23,7 @@ std::pair<ov::PartialShape, std::vector<ov::PartialShape>> get_numpy_broadcast_p
ov::PartialShape target_shape = input_shapes.front();
for (size_t i = 1; i < input_shapes.size(); i++) {
if (!ov::PartialShape::broadcast_merge_into(target_shape, input_shapes[i], op::AutoBroadcastType::NUMPY))
throw ngraph::ngraph_error("InsertMoveBroadcast: Failed broadcast-merge input shapes");
OPENVINO_THROW("InsertMoveBroadcast: Failed broadcast-merge input shapes");
}
std::vector<ov::PartialShape> normalized_shapes;
for (const auto& input : input_shapes) {
@@ -358,7 +358,7 @@ ngraph::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets() {
}
if (body_results.size() != subgraph_result_inputs.size()) {
throw ngraph_error("body results and node results size mismatch during subgraph collapse");
OPENVINO_THROW("body results and node results size mismatch during subgraph collapse");
}
// todo: move this plugin-specific constraint to the plugin callback
@@ -36,7 +36,7 @@ int64_t GetTopologicalOrder(const std::shared_ptr<const Node> &node) {
auto &rt = node->get_rt_info();
const auto rinfo = rt.find("TopologicalOrder");
if (rinfo == rt.end())
throw ngraph_error("Topological order is required, but not set.");
OPENVINO_THROW("Topological order is required, but not set.");
return rinfo->second.as<int64_t>();
}
+6 -6
View File
@@ -74,7 +74,7 @@ std::vector<size_t> get_node_output_layout(const Node* node) {
if (!node)
return {};
if (node->is_dynamic())
throw ngraph_error("It's illegal to call get_node_output_layout for dynamic nodes");
OPENVINO_THROW("It's illegal to call get_node_output_layout for dynamic nodes");
auto &rt = node->get_rt_info();
const auto rinfo = rt.find("Layout");
if (rinfo != rt.end()) {
@@ -82,7 +82,7 @@ std::vector<size_t> get_node_output_layout(const Node* node) {
// This might be a little costy, but still useful sanity check. Remove if proved to be unacceptably heavy.
std::set<size_t> unique_elements(layout.begin(), layout.end());
if (unique_elements.size() < layout.size())
throw ngraph_error("Layout must contain only unique dimension indexes");
OPENVINO_THROW("Layout must contain only unique dimension indexes");
return layout;
} else {
return {};
@@ -94,13 +94,13 @@ ov::PartialShape get_reordered_planar_shape(const ov::PartialShape& shape, const
return shape;
std::vector<Dimension> reordered_shape(layout.size());
if (shape.rank().is_dynamic())
throw ngraph_error("get_reordered_planar_shape can't be called for outputs with dynamic rank");
OPENVINO_THROW("get_reordered_planar_shape can't be called for outputs with dynamic rank");
const size_t rank = shape.rank().get_length();
if (layout.size() > rank)
throw ngraph_error("Layout rank can't be larger than tensor rank");
OPENVINO_THROW("Layout rank can't be larger than tensor rank");
// Note that it can be smaller though, for example tensor shape can be prepended with 1 for scheduling purposes
if (std::any_of(layout.begin(), layout.end(), [=](size_t x) {return x >= rank;}))
throw ngraph_error("Invalid layout detected: all layout indexes must be smaller than the tensor rank");
OPENVINO_THROW("Invalid layout detected: all layout indexes must be smaller than the tensor rank");
for (size_t i = 0; i < layout.size(); i++)
reordered_shape[i] = shape[layout[i]];
return reordered_shape;
@@ -110,7 +110,7 @@ ov::PartialShape get_port_planar_shape(const Output<Node>& out) {
std::vector<size_t> layout = get_node_output_layout(out.get_node_shared_ptr());
const auto& tensor = out.get_tensor_ptr();
if (!tensor)
throw ngraph_error("get_port_planar_shape can't be called for an uninitialized output tensor");
OPENVINO_THROW("get_port_planar_shape can't be called for an uninitialized output tensor");
auto tensor_shape = tensor->get_partial_shape();
return get_reordered_planar_shape(tensor_shape, layout);
}
@@ -33,7 +33,7 @@ std::shared_ptr<Node> op::internal::MulticlassNmsIEInternal::clone_with_new_inpu
} else if (new_args.size() == 2) {
return std::make_shared<MulticlassNmsIEInternal>(new_args.at(0), new_args.at(1), m_attrs);
}
throw ngraph::ngraph_error("Unsupported number of inputs: " + std::to_string(new_args.size()));
OPENVINO_THROW("Unsupported number of inputs: " + std::to_string(new_args.size()));
}
void op::internal::MulticlassNmsIEInternal::validate_and_infer_types() {
@@ -70,7 +70,7 @@ std::shared_ptr<Node> op::internal::NonMaxSuppressionIEInternal::clone_with_new_
m_sort_result_descending,
m_output_type);
}
throw ngraph::ngraph_error("Unsupported number of inputs: " + std::to_string(new_args.size()));
OPENVINO_THROW("Unsupported number of inputs: " + std::to_string(new_args.size()));
}
bool op::internal::NonMaxSuppressionIEInternal::visit_attributes(AttributeVisitor& visitor) {
@@ -186,7 +186,7 @@ Attribute get(const T& port) {
if (res != attrs.end()) {
return res->second.template as<Attribute>();
}
throw Exception("reverse_input_channel_index is missing in given port");
OPENVINO_THROW("reverse_input_channel_index is missing in given port");
}
template <typename T, typename = is_port<T>>
@@ -504,7 +504,7 @@ bool fuse_type_to_nms3(const std::shared_ptr<ngraph::Node>& node, const precisio
if (to == ov::element::i32 || to == ov::element::i64) {
nms->set_output_type(to);
} else {
throw Exception("Type: " + to.get_type_name() + " is not supported for NMS3");
OPENVINO_THROW("Type: " + to.get_type_name() + " is not supported for NMS3");
}
return true;
}
@@ -520,7 +520,7 @@ bool fuse_type_to_nms4(const std::shared_ptr<ngraph::Node>& node, const precisio
if (to == ov::element::i32 || to == ov::element::i64) {
nms->set_output_type(to);
} else {
throw Exception("Type: " + to.get_type_name() + " is not supported for NMS4");
OPENVINO_THROW("Type: " + to.get_type_name() + " is not supported for NMS4");
}
return true;
}
@@ -815,7 +815,7 @@ std::shared_ptr<ngraph::Node> change_constant_precision(std::shared_ptr<opset4::
new_constant->output(0).set_names(constant->output(0).get_names());
auto* dst_data = const_cast<dst_type*>(reinterpret_cast<const dst_type*>(new_constant->get_data_ptr()));
if (dst_data == nullptr)
throw Exception("Can't get destination data pointer");
OPENVINO_THROW("Can't get destination data pointer");
for (size_t i = 0; i < size; ++i) {
dst_data[i] = convert_value<src_type, dst_type>(src_data[i]);
@@ -836,7 +836,7 @@ std::shared_ptr<Node> change_constant_precision<ov::element::Type_t::f16, ov::el
new_constant->output(0).set_names(constant->output(0).get_names());
auto* dst_data = const_cast<dst_type*>(reinterpret_cast<const dst_type*>(new_constant->get_data_ptr()));
if (dst_data == nullptr)
throw Exception("Can't get destination data pointer");
OPENVINO_THROW("Can't get destination data pointer");
ngraph::runtime::reference::convert<src_type, dst_type>(src_data, dst_data, size);
@@ -856,7 +856,7 @@ std::shared_ptr<Node> change_constant_precision<ov::element::Type_t::f32, ov::el
new_constant->output(0).set_names(constant->output(0).get_names());
auto* dst_data = const_cast<dst_type*>(reinterpret_cast<const dst_type*>(new_constant->get_data_ptr()));
if (dst_data == nullptr)
throw Exception("Can't get destination data pointer");
OPENVINO_THROW("Can't get destination data pointer");
ngraph::runtime::reference::convert<src_type, dst_type>(src_data, dst_data, size);
@@ -957,15 +957,15 @@ std::shared_ptr<Node> convert_low_precisions_int(std::shared_ptr<opset4::Constan
// source and destination data type should be real
if (!supported_integer_precisions.count(src_type) || (src_type.size() * 8) % src_type.bitwidth() ||
(to.size() * 8) % to.bitwidth() || to.is_real() || to.bitwidth() < src_type.bitwidth())
throw Exception("Convert low precision for " + constant->get_element_type().get_type_name() + " to " +
to.get_type_name() + " is not implemented!");
OPENVINO_THROW("Convert low precision for " + constant->get_element_type().get_type_name() + " to " +
to.get_type_name() + " is not implemented!");
// Create a new constant operation and get destination data
auto new_constant = std::make_shared<opset4::Constant>(to, constant->get_shape());
auto* dst_data = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(new_constant->get_data_ptr()));
// Check pointers
if (src_data == nullptr || dst_data == nullptr)
throw Exception("Can't get data pointer");
OPENVINO_THROW("Can't get data pointer");
// Convert values
const auto size = shape_size(constant->get_shape());
@@ -1019,7 +1019,7 @@ std::shared_ptr<Node> convert_low_precisions_int(std::shared_ptr<opset4::Constan
src_type.is_signed());
break;
default:
throw Exception("Unsupported element size!");
OPENVINO_THROW("Unsupported element size!");
}
// Calculate offsets and indexes
if (src_type.bitwidth() < 8) {
@@ -1084,8 +1084,8 @@ bool fuse_type_to_constant(const std::shared_ptr<ngraph::Node>& node,
} else if (from == ov::element::i4 || from == ov::element::u4 || from == ov::element::u1) {
new_const = convert_low_precisions_int(constant, to);
} else {
throw Exception("Precision conversion from " + from.get_type_name() + " to " + to.get_type_name() +
" is not supported");
OPENVINO_THROW("Precision conversion from " + from.get_type_name() + " to " + to.get_type_name() +
" is not supported");
}
for (auto& output : consumers) {
output.replace_source_output(new_const);
@@ -68,7 +68,7 @@ ov::pass::ConvertNMS9ToNMSIEInternal::ConvertNMS9ToNMSIEInternal() {
center_point_box = 0;
break;
default:
throw Exception("NonMaxSuppression layer " + nms_9->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms_9->get_friendly_name() + " has unsupported box encoding");
}
std::shared_ptr<op::internal::NonMaxSuppressionIEInternal> nms_legacy{nullptr};
@@ -68,7 +68,7 @@ ov::pass::ConvertNMSToNMSIEInternal::ConvertNMSToNMSIEInternal() {
center_point_box = 0;
break;
default:
throw Exception("NonMaxSuppression layer " + nms_5->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms_5->get_friendly_name() + " has unsupported box encoding");
}
std::shared_ptr<op::internal::NonMaxSuppressionIEInternal> nms_legacy{nullptr};
@@ -42,7 +42,7 @@ NMSAttributes get_nms4_attrs(const std::shared_ptr<ov::opset4::NonMaxSuppression
attrs.box_encoding = ::ov::opset5::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms4->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms4->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms4->get_sort_result_descending();
@@ -67,7 +67,7 @@ NMSAttributes get_nms3_attrs(const std::shared_ptr<ov::opset3::NonMaxSuppression
attrs.box_encoding = ::ov::opset5::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms3->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms3->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms3->get_sort_result_descending();
@@ -92,7 +92,7 @@ NMSAttributes get_nms1_attrs(const std::shared_ptr<ov::opset1::NonMaxSuppression
attrs.box_encoding = ::ov::opset5::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms1->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms1->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms1->get_sort_result_descending();
@@ -43,7 +43,7 @@ NMS9Attributes get_nms9_attrs_from_nms5(const std::shared_ptr<ov::opset5::NonMax
attrs.box_encoding = ::ov::opset9::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms5->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms5->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms5->get_sort_result_descending();
@@ -68,7 +68,7 @@ NMS9Attributes get_nms9_attrs_from_nms4(const std::shared_ptr<ov::opset4::NonMax
attrs.box_encoding = ::ov::opset9::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms4->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms4->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms4->get_sort_result_descending();
@@ -93,7 +93,7 @@ NMS9Attributes get_nms9_attrs_from_nms3(const std::shared_ptr<ov::opset3::NonMax
attrs.box_encoding = ::ov::opset9::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms3->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms3->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms3->get_sort_result_descending();
@@ -118,7 +118,7 @@ NMS9Attributes get_nms9_attrs_from_nms1(const std::shared_ptr<ov::opset1::NonMax
attrs.box_encoding = ::ov::opset9::NonMaxSuppression::BoxEncodingType::CORNER;
break;
default:
throw Exception("NonMaxSuppression layer " + nms1->get_friendly_name() + " has unsupported box encoding");
OPENVINO_THROW("NonMaxSuppression layer " + nms1->get_friendly_name() + " has unsupported box encoding");
}
attrs.sort_result_descending = nms1->get_sort_result_descending();
@@ -37,7 +37,7 @@ ov::pass::ConvertROIAlign3To9::ConvertROIAlign3To9() {
break;
}
default: {
throw Exception("unsupported PoolingMode ");
OPENVINO_THROW("unsupported PoolingMode ");
}
}
@@ -41,7 +41,7 @@ ov::pass::ConvertROIAlign9To3::ConvertROIAlign9To3() {
break;
}
default: {
throw Exception("unsupported PoolingMode ");
OPENVINO_THROW("unsupported PoolingMode ");
}
}
@@ -66,7 +66,7 @@ ov::pass::ConvertScatterElementsToScatter::ConvertScatterElementsToScatter() {
uint64_t l, r;
Range(const uint64_t& l, const uint64_t& r) : l(l), r(r) {
if (l > r)
throw Exception("Range values are inconsistent");
OPENVINO_THROW("Range values are inconsistent");
}
uint64_t size() const {
@@ -52,7 +52,7 @@ Any PrimitivesPriority::merge(const ngraph::NodeVector& nodes) const {
}
if (unique_pp.size() > 1) {
throw ngraph_error("PrimitivesPriority no rule defined for multiple values.");
OPENVINO_THROW("PrimitivesPriority no rule defined for multiple values.");
}
std::string final_primitives_priority;
@@ -113,7 +113,7 @@ public:
false /*any*/,
ngraph::op::RoundingType::FLOOR /*any*/);
} else {
throw ngraph::ngraph_error("Unsupported Reduce type!");
OPENVINO_THROW("Unsupported Reduce type!");
}
}
@@ -35,7 +35,7 @@ std::shared_ptr<ngraph::Function> get_initial_function(const ngraph::PartialShap
auto broadcast_len = broadcast_shape.rank().get_length();
if (std::numeric_limits<size_t>::max() < (size_t)broadcast_len) {
throw ngraph::ngraph_error("broadcast_len cannot be represented in size_t");
OPENVINO_THROW("broadcast_len cannot be represented in size_t");
}
auto broadcast_shape_param =
@@ -47,7 +47,7 @@ TEST_F(TransformationTestsF, GatherNegativeIndicesNormalize) {
auto const_add = ngraph::get_constant_from_source(add);
OPENVINO_SUPPRESS_DEPRECATED_END
if (const_add == nullptr)
throw ngraph::ngraph_error("indices should've been constant folded");
OPENVINO_THROW("indices should've been constant folded");
auto gather = std::make_shared<ngraph::opset7::Gather>(data, const_add, axis);
function_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{gather}, ngraph::ParameterVector{data});
@@ -84,7 +84,7 @@ TEST_F(TransformationTestsF, GatherNegativeIndicesNormalize_neg_axis) {
auto const_add = ngraph::get_constant_from_source(add);
OPENVINO_SUPPRESS_DEPRECATED_END
if (const_add == nullptr)
throw ngraph::ngraph_error("indices should've been constant folded");
OPENVINO_THROW("indices should've been constant folded");
auto gather = std::make_shared<ngraph::opset7::Gather>(data, const_add, axis);
function_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{gather}, ngraph::ParameterVector{data});
@@ -121,7 +121,7 @@ TEST_F(TransformationTestsF, GatherNegativeIndicesNormalize_dif_input_types) {
auto const_add = ngraph::get_constant_from_source(add);
OPENVINO_SUPPRESS_DEPRECATED_END
if (const_add == nullptr)
throw ngraph::ngraph_error("indices should've been constant folded");
OPENVINO_THROW("indices should've been constant folded");
auto gather = std::make_shared<ngraph::opset7::Gather>(data, const_add, axis);
function_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{gather}, ngraph::ParameterVector{data});
@@ -21,6 +21,7 @@ std::shared_ptr<Node> make_constant(const element::Type& type, const Shape& shap
# pragma GCC diagnostic error "-Wswitch"
# pragma GCC diagnostic error "-Wswitch-enum"
#endif
std::string unsupported_data_type;
switch (type) {
case element::Type_t::f32:
val =
@@ -84,18 +85,27 @@ std::shared_ptr<Node> make_constant(const element::Type& type, const Shape& shap
std::vector<uint8_t>{static_cast<uint8_t>(num)});
break;
case element::Type_t::dynamic:
throw ngraph_error("make_constant: Unsupported element type 'dynamic'");
unsupported_data_type = "dynamic";
break;
case element::Type_t::boolean:
throw ngraph_error("make_constant: Unsupported element type 'boolean'");
unsupported_data_type = "boolean";
break;
case element::Type_t::u1:
throw ngraph_error("make_constant: Unsupported element type 'u1'");
unsupported_data_type = "u1";
break;
case element::Type_t::i4:
throw ngraph_error("make_constant: Unsupported element type 'i4'");
unsupported_data_type = "i4";
break;
case element::Type_t::u4:
throw ngraph_error("make_constant: Unsupported element type 'u4'");
unsupported_data_type = "u4";
break;
case element::Type_t::undefined:
throw ngraph_error("make_constant: Unsupported element type 'undefined'");
unsupported_data_type = "undefined";
break;
}
if (!unsupported_data_type.empty())
OPENVINO_THROW("make_constant: Unsupported element type '", unsupported_data_type, "'");
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
# pragma GCC diagnostic pop
#endif
@@ -20,11 +20,13 @@ using namespace std;
namespace ngraph {
namespace builder {
OPENVINO_SUPPRESS_DEPRECATED_START
numpy_autobroadcast_incompatible_shapes::numpy_autobroadcast_incompatible_shapes(const Shape& shape1,
const Shape& shape2)
: ngraph_error(error_str(shape1, shape2)),
m_shape1(shape1),
m_shape2(shape2) {}
OPENVINO_SUPPRESS_DEPRECATED_END
string numpy_autobroadcast_incompatible_shapes::error_str(const Shape& shape1, const Shape& shape2) {
ostringstream os;
@@ -62,7 +62,7 @@ std::shared_ptr<Node> make_constant_from_double(const element::Type& type, const
break;
}
default:
throw std::runtime_error("Unsupported data type during make_constant_from_double");
OPENVINO_THROW("Unsupported data type during make_constant_from_double");
break;
}
return result;
@@ -29,7 +29,7 @@ public:
void add_in_place_oi_pair(const struct oi_pair& oi) {
for (const auto& e : m_in_place_oi_pairs) {
if (e.input == oi.input || e.output == oi.output) {
throw ngraph_error("In_place hint conflicts with an existing entry");
OPENVINO_THROW("In_place hint conflicts with an existing entry");
}
}
m_in_place_oi_pairs.emplace_back(oi);
+45 -31
View File
@@ -8,17 +8,32 @@
#include <stdexcept>
#include "openvino/core/core_visibility.hpp"
#include "openvino/core/deprecated.hpp"
namespace ov {
struct CheckLocInfo {
const char* file;
int line;
const char* check_string;
};
/// Base error for ov runtime errors.
class OPENVINO_API Exception : public std::runtime_error {
public:
OPENVINO_DEPRECATED("This constructor is deprecated and will be removed, please use OPENVINO_THROW instead")
explicit Exception(const std::string& what_arg) : std::runtime_error(what_arg) {}
explicit Exception(const char* what_arg) : std::runtime_error(what_arg) {}
OPENVINO_DEPRECATED("This constructor is deprecated and will be removed, please use OPENVINO_THROW instead")
explicit Exception(const std::stringstream& what_arg) : std::runtime_error(what_arg.str()) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
virtual ~Exception();
protected:
static std::string make_what(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
};
static inline std::ostream& write_all_to_stream(std::ostream& str) {
@@ -29,31 +44,30 @@ static inline std::ostream& write_all_to_stream(std::ostream& str, const T& arg,
return write_all_to_stream(str << arg, args...);
}
struct CheckLocInfo {
const char* file;
int line;
const char* check_string;
};
/// Base class for check failure exceptions.
class OPENVINO_API AssertFailure : public Exception {
public:
AssertFailure(const CheckLocInfo& check_loc_info, const std::string& context_info, const std::string& explanation)
: Exception(make_what(check_loc_info, context_info, explanation)) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
~AssertFailure() override;
private:
static std::string make_what(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
protected:
OPENVINO_SUPPRESS_DEPRECATED_START
explicit AssertFailure(const std::string& what_arg) : ov::Exception(what_arg) {}
OPENVINO_SUPPRESS_DEPRECATED_END
};
/// Exception class to be thrown on not implemented code
class OPENVINO_API NotImplemented : public AssertFailure {
public:
NotImplemented(const CheckLocInfo& check_loc_info, const std::string& context_info, const std::string& explanation)
: AssertFailure(check_loc_info, context_info, explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
~NotImplemented() override;
protected:
explicit NotImplemented(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
} // namespace ov
@@ -119,20 +133,20 @@ public:
// The "..." may be filled with expressions of any type that has an "operator<<" overload for
// insertion into std::ostream.
//
#define OPENVINO_ASSERT_HELPER2(exc_class, ctx, check, ...) \
do { \
if (!(check)) { \
::std::stringstream ss___; \
::ov::write_all_to_stream(ss___, __VA_ARGS__); \
throw exc_class((::ov::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ss___.str()); \
} \
#define OPENVINO_ASSERT_HELPER2(exc_class, ctx, check, ...) \
do { \
if (!(check)) { \
::std::stringstream ss___; \
::ov::write_all_to_stream(ss___, __VA_ARGS__); \
exc_class::create((::ov::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ss___.str()); \
} \
} while (0)
#define OPENVINO_ASSERT_HELPER1(exc_class, ctx, check) \
do { \
if (!(check)) { \
throw exc_class((::ov::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ""); \
} \
#define OPENVINO_ASSERT_HELPER1(exc_class, ctx, check) \
do { \
if (!(check)) { \
exc_class::create((::ov::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ""); \
} \
} while (0)
/// \brief Macro to check whether a boolean condition holds.
@@ -147,8 +161,8 @@ public:
/// implemented with OPENVINO_ASSERT macro.
/// \param ... Additional error message that should describe why that execution path is unreachable.
/// \throws ::ov::AssertFailure if the macro is executed.
// TODO: throw ov::Exception after migration to functions
#define OPENVINO_THROW(...) OPENVINO_ASSERT(false, __VA_ARGS__)
// TODO: OPENVINO_THROW after migration to functions
#define OPENVINO_THROW(...) OPENVINO_ASSERT_HELPER(::ov::Exception, "", false, __VA_ARGS__)
#define OPENVINO_ASSERT_HELPER(exc_class, ctx, ...) CALL_OVERLOAD(OPENVINO_ASSERT_HELPER, exc_class, ctx, __VA_ARGS__)
#define OPENVINO_NOT_IMPLEMENTED OPENVINO_ASSERT_HELPER(::ov::NotImplemented, "", false, "Not Implemented", "")
@@ -15,6 +15,7 @@
#include <vector>
#include "openvino/core/core_visibility.hpp"
#include "openvino/core/except.hpp"
#include "openvino/core/model.hpp"
#include "openvino/core/node.hpp"
#include "openvino/op/parameter.hpp"
@@ -238,8 +239,9 @@ std::vector<std::shared_ptr<Node>> topological_sort(T root_nodes) {
// Node may be at the top of `nodes_to_do` not more than twice before it's added to `nodes_done` -
// when visited and placed in `nodes_to_do` and after the subtree traversal is finished.
// Otherwise it's a loop.
throw Exception("Loop detected during topological sort starting from '" + node->get_friendly_name() +
"' node.");
OPENVINO_THROW("Loop detected during topological sort starting from '",
node->get_friendly_name(),
"' node.");
size_t arg_count = node->get_input_size();
for (size_t i = 0; i < arg_count; ++i) {
+7 -2
View File
@@ -530,9 +530,14 @@ using RawNodeOutputMap = std::map<RawNodeOutput, Output<Node>>;
class OPENVINO_API NodeValidationFailure : public ov::AssertFailure {
public:
NodeValidationFailure(const ov::CheckLocInfo& check_loc_info, const Node* node, const std::string& explanation)
: AssertFailure(check_loc_info, node_validation_failure_loc_string(node), explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const Node* node,
const std::string& explanation);
protected:
explicit NodeValidationFailure(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
} // namespace ov
#define NODE_VALIDATION_CHECK(node, ...) OPENVINO_ASSERT_HELPER(::ov::NodeValidationFailure, (node), __VA_ARGS__)
@@ -22,7 +22,9 @@ namespace op {
namespace util {
namespace error {
struct UnknownActivationFunction : Exception {
OPENVINO_SUPPRESS_DEPRECATED_START
UnknownActivationFunction(const std::string& func_name) : Exception{"Unknown activation function: " + func_name} {}
OPENVINO_SUPPRESS_DEPRECATED_END
};
} // namespace error
@@ -105,7 +105,7 @@ public:
for (const auto& arg : node->input_values()) {
if (auto t_casted = ov::as_type_ptr<T>(arg.get_node_shared_ptr())) {
if (matched) {
throw Exception("There's more than two arguments of the same type");
OPENVINO_THROW("There's more than two arguments of the same type");
} else {
matched = t_casted;
}
@@ -231,7 +231,7 @@ public:
/// describing an individual cell
NodeVector get_bound_nodes_for_pattern(const std::shared_ptr<Node>& pattern) const {
if (m_matches.count(pattern) == 0) {
throw Exception("No bound nodes for a given label");
OPENVINO_THROW("No bound nodes for a given label");
}
return as_node_vector(m_matches.at(pattern));
@@ -26,7 +26,7 @@ public:
AnyOf(const element::Type& type, const PartialShape& s, ValuePredicate pred, const OutputVector& wrapped_values)
: Pattern(wrapped_values, pred) {
if (wrapped_values.size() != 1) {
throw Exception("AnyOf expects exactly one argument");
OPENVINO_THROW("AnyOf expects exactly one argument");
}
set_output_type(0, type, s);
}
@@ -85,7 +85,7 @@ public:
Pattern(const OutputVector& patterns) : Pattern(patterns, nullptr) {}
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& /* new_args */) const override {
throw Exception("Uncopyable");
OPENVINO_THROW("Uncopyable");
}
ValuePredicate get_predicate() const;
@@ -40,11 +40,11 @@ void CTCLoss(const T* logits,
U actualTargetLen = labelsLength[b];
if (static_cast<size_t>(actualLogitLen) > maxTime || static_cast<size_t>(actualTargetLen) > maxTime ||
actualTargetLen > actualLogitLen) {
throw ngraph_error(std::string("Logit or label length cannot greater than max sequence"
"length. Also a label length cannot be greater than a"
"logit length.\nMaxSeqLen: ") +
std::to_string(maxTime) + "; Logit len: " + std::to_string(actualLogitLen) +
"; Label len: " + std::to_string(actualTargetLen));
OPENVINO_THROW(std::string("Logit or label length cannot greater than max sequence"
"length. Also a label length cannot be greater than a"
"logit length.\nMaxSeqLen: ") +
std::to_string(maxTime) + "; Logit len: " + std::to_string(actualLogitLen) +
"; Label len: " + std::to_string(actualTargetLen));
}
const U* target = &labels[b * maxTime];
@@ -32,11 +32,10 @@ void embeddingBagOffsetsSum(const T* emb_table,
auto get_indices =
[&](size_t emb_index, const U*& indices_ref, size_t& indices_num, size_t& weights_idx, bool& with_weights) {
if (emb_index >= offsets_size)
throw ngraph_error("Invalid embedding bag index.");
OPENVINO_THROW("Invalid embedding bag index.");
if (static_cast<size_t>(offsets[emb_index]) >= indices_count)
throw ngraph_error(std::string("Offset value exceeds indices size in the model.\noffset: ") +
std::to_string(offsets[emb_index]) +
"; indices size: " + std::to_string(indices_count));
OPENVINO_THROW(std::string("Offset value exceeds indices size in the model.\noffset: ") +
std::to_string(offsets[emb_index]) + "; indices size: " + std::to_string(indices_count));
indices_ref = nullptr;
indices_num = 0lu;
@@ -33,7 +33,7 @@ void embeddingSegmentsSum(const T* embTable,
for (size_t index = 0; index < indices_len; index++) {
size_t obi = segmentIds[index];
if (obi >= segments_num)
throw ngraph_error("Segment index could not be more than segments number");
OPENVINO_THROW("Segment index could not be more than segments number");
size_t dst_index = obi * embDepth;
size_t src_index = indices[index] * embDepth;
@@ -51,7 +51,7 @@ void embeddingSegmentsSum(const T* embTable,
if (defaultIndex != nullptr) {
U defIndex = defaultIndex[0];
if (defIndex < U(0) && static_cast<size_t>(defIndex) >= embTableShape[0])
throw ngraph_error(std::string("Invalid default index") + std::to_string(defIndex));
OPENVINO_THROW(std::string("Invalid default index") + std::to_string(defIndex));
for (size_t obi = 0; obi < segments_num; obi++) {
bool found = false;
for (size_t index = 0; index < indices_len; index++) {
@@ -95,15 +95,15 @@ void extract_image_patches(const std::shared_ptr<op::ExtractImagePatches> extImg
int64_t iwKW = iw0 + kw * RW;
int64_t dst_idx = ob_OCOHOW_ohOW_ow + oc * OH_OW;
if (dst_idx >= OB_OC_OH_OW)
throw ngraph_error("ExtractImagePatches. Destination index is out of "
"bounds.");
OPENVINO_THROW("ExtractImagePatches. Destination index is out of "
"bounds.");
if (ihKH < 0 || ihKH >= IH || iwKW < 0 || iwKW >= IW) {
out[dst_idx] = T(0);
} else {
int64_t src_idx = ib_ICIHIW_ihKH_IW + ic * IH_IW + iwKW;
if (src_idx >= IB_IC_IH_IW)
throw ngraph_error("ExtractImagePatches. Source index is out of "
"bounds.");
OPENVINO_THROW("ExtractImagePatches. Source index is out of "
"bounds.");
out[dst_idx] = input[src_idx];
}
}
@@ -131,7 +131,7 @@ void gru_cell(const T* X,
} else if (activation == "tanh") {
reference::tanh(gate.data(), gate.data(), gate.size());
} else {
throw ngraph_error("Activation function " + activation + " is not supported.");
OPENVINO_THROW("Activation function " + activation + " is not supported.");
}
};
@@ -425,7 +425,7 @@ void InterpolateEval<T>::linear_onnx_func(const T* input_data, T* out) {
}
if (!correct_axes)
throw ngraph_error("Axes are not correct!");
OPENVINO_THROW("Axes are not correct!");
const auto info = helper.get_info_for_generic_linear_onnx();
@@ -122,7 +122,7 @@ void lstm_cell(const T* X,
} else if (activation == "tanh") {
reference::tanh(gate.data(), gate.data(), gate.size());
} else {
throw ngraph_error("Activation function " + activation + " is not supported.");
OPENVINO_THROW("Activation function " + activation + " is not supported.");
}
};
@@ -228,7 +228,7 @@ void lstm_cell_v1(const T* X,
auto all_gates_shape_size = gate_shape_size * 4;
if (weight_format != ov::op::LSTMWeightsFormat::FICO) {
throw ngraph_error("Only LSTMWeightFormat = FICO is supported.");
OPENVINO_THROW("Only LSTMWeightFormat = FICO is supported.");
}
// Xt*(W^T)
std::vector<T> Xt_W(all_gates_shape_size);
@@ -270,7 +270,7 @@ void lstm_cell_v1(const T* X,
} else if (activation == "tanh") {
reference::tanh(gate.data(), gate.data(), gate.size());
} else {
throw ngraph_error("Activation function " + activation + " is not supported.");
OPENVINO_THROW("Activation function " + activation + " is not supported.");
}
};
@@ -88,7 +88,7 @@ void rnn_cell(const T* X,
} else if (activation_f == "tanh") {
reference::tanh(i_t.data(), dst_data, i_t.size());
} else {
throw ngraph_error("Activation function " + activation_f + " is not supported.");
OPENVINO_THROW("Activation function " + activation_f + " is not supported.");
}
}
} // namespace reference
@@ -58,7 +58,7 @@ void roi_align(const T* feature_maps,
break;
}
default: {
throw ngraph_error(std::string("Not supported aligned_mode"));
OPENVINO_THROW(std::string("Not supported aligned_mode"));
break;
}
}
@@ -333,9 +333,9 @@ void experimental_detectron_proposals_single_image_postprocessing(void* prois,
memcpy(scores_ptr, output_scores.data(), shape_size(output_scores_shape) * sizeof(float));
} break;
default:;
throw ngraph_error("Unsupported input data type: "
"ExperimentalDetectronGenerateProposalsSingleImage operation"
" supports only fp32, fp16, or bf16 data.");
OPENVINO_THROW("Unsupported input data type: "
"ExperimentalDetectronGenerateProposalsSingleImage operation"
" supports only fp32, fp16, or bf16 data.");
}
}
} // namespace reference
@@ -11,6 +11,7 @@
#include "ngraph/check.hpp"
#include "ngraph/coordinate_transform.hpp"
#include "openvino/core/except.hpp"
using namespace ngraph;
@@ -33,7 +34,7 @@ static size_t _asIndex(const char* source, const element::Type& element_type) {
return static_cast<size_t>(tmpBuff);
}
default: {
throw ngraph_error(std::string("Unsupported input data type: ") + element_type.get_type_name());
OPENVINO_THROW("Unsupported input data type: ", element_type.get_type_name());
}
}
}
@@ -50,16 +51,16 @@ void runtime::reference::gather_tree(const char* step_ids,
const Shape& end_token_shape,
const element::Type& element_type) {
if (step_ids_shape != parent_ids_shape) {
throw ngraph_error("step_ids shape and parent_ids shape must be the same");
OPENVINO_THROW("step_ids shape and parent_ids shape must be the same");
}
if (step_ids_shape.size() != 3) {
throw ngraph_error("step_ids must be a 3-tensor");
OPENVINO_THROW("step_ids must be a 3-tensor");
}
if (!is_vector(max_seq_len_shape)) {
throw ngraph_error("max_seq_len must be a vector");
OPENVINO_THROW("max_seq_len must be a vector");
}
if (!is_scalar(end_token_shape)) {
throw ngraph_error("end_token must be a scalar");
OPENVINO_THROW("end_token must be a scalar");
}
const size_t max_time = step_ids_shape.at(0);
@@ -69,7 +70,7 @@ void runtime::reference::gather_tree(const char* step_ids,
const size_t elem_size = element_type.size();
if (max_seq_len_shape.front() != batch_size) {
throw ngraph_error("max_seq_len must have size of BATCH_SIZE");
OPENVINO_THROW("max_seq_len must have size of BATCH_SIZE");
}
const auto in_strides = row_major_strides(step_ids_shape);
@@ -398,9 +398,9 @@ void generate_proposals_postprocessing(void* prois,
memcpy(scores_ptr, output_scores.data(), shape_size(output_scores_shape) * sizeof(float));
} break;
default:;
throw ngraph_error("Unsupported input data type: "
"GenerateProposals operation"
" supports only fp32, fp16, or bf16 data.");
OPENVINO_THROW("Unsupported input data type: "
"GenerateProposals operation"
" supports only fp32, fp16, or bf16 data.");
}
for (size_t i = 0; i < num_rois.size(); i++) {
@@ -414,8 +414,8 @@ void generate_proposals_postprocessing(void* prois,
roi_num_ptr[i] = static_cast<int64_t>(num_rois[i]);
} break;
default:;
throw ngraph_error("Unsupported data type on output port 3: "
" supports only int32 or int64.");
OPENVINO_THROW("Unsupported data type on output port 3: "
" supports only int32 or int64.");
}
}
}
@@ -7,6 +7,7 @@
#include <ctime>
#include "ngraph/shape.hpp"
#include "openvino/core/except.hpp"
namespace ngraph {
namespace runtime {
@@ -304,7 +305,7 @@ std::pair<uint64_t, uint64_t> random_uniform(const uint64_t* out_shape,
break;
}
default:
throw ngraph_error("Unsupported type of RandomUniform: " + elem_type.get_type_name());
OPENVINO_THROW("Unsupported type of RandomUniform: ", elem_type.get_type_name());
}
if (++n == 0)
++counter;
@@ -29,8 +29,8 @@ void reorg_yolo(const char* arg, char* out, const Shape& in_shape, int64_t strid
size_t impl_out_C = in_C / (stride * stride);
if (impl_out_C == 0) {
throw ngraph_error("ReorgYolo. For [N, C, H, W] input shape, C >= (stride*stride) is "
"required.");
OPENVINO_THROW("ReorgYolo. For [N, C, H, W] input shape, C >= (stride*stride) is "
"required.");
}
size_t impl_out_H = in_H * stride;
size_t impl_out_W = in_W * stride;
+2 -1
View File
@@ -5,6 +5,7 @@
#include "openvino/core/descriptor/tensor.hpp"
#include "ngraph/node.hpp"
#include "openvino/core/except.hpp"
using namespace std;
@@ -106,7 +107,7 @@ const std::unordered_set<std::string>& ov::descriptor::Tensor::get_names() const
const std::string& ov::descriptor::Tensor::get_any_name() const {
if (m_name_it == m_names.cend()) {
throw ngraph::ngraph_error("Attempt to get a name for a Tensor without names");
OPENVINO_THROW("Attempt to get a name for a Tensor without names");
}
return *m_name_it;
}
+23 -3
View File
@@ -4,9 +4,17 @@
#include "openvino/core/except.hpp"
std::string ov::AssertFailure::make_what(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
void ov::Exception::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
OPENVINO_SUPPRESS_DEPRECATED_START
throw ov::Exception(make_what(check_loc_info, context_info, explanation));
OPENVINO_SUPPRESS_DEPRECATED_END
}
std::string ov::Exception::make_what(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
// Use relative path only for internal code
auto getRelativePath = [](const std::string& path) -> std::string {
// Path to local OpenVINO repository
@@ -31,5 +39,17 @@ std::string ov::AssertFailure::make_what(const CheckLocInfo& check_loc_info,
}
ov::Exception::~Exception() = default;
void ov::AssertFailure::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::AssertFailure(make_what(check_loc_info, context_info, explanation));
}
ov::AssertFailure::~AssertFailure() = default;
void ov::NotImplemented::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::NotImplemented(make_what(check_loc_info, context_info, explanation));
}
ov::NotImplemented::~NotImplemented() = default;
+4 -4
View File
@@ -114,7 +114,7 @@ void ov::replace_node(const std::shared_ptr<Node>& target,
const std::shared_ptr<Node>& replacement,
const std::vector<int64_t>& output_order) {
if (ngraph::op::is_output(target)) {
throw ngraph::ngraph_error("Result nodes cannot be replaced.");
OPENVINO_THROW("Result nodes cannot be replaced.");
}
NGRAPH_CHECK(target->get_output_size() == output_order.size(),
@@ -140,7 +140,7 @@ void ov::replace_node(const std::shared_ptr<Node>& target,
void ov::replace_node(const std::shared_ptr<Node>& target, const OutputVector& replacement_values) {
if (ngraph::op::is_output(target)) {
throw ngraph::ngraph_error("Result nodes cannot be replaced.");
OPENVINO_THROW("Result nodes cannot be replaced.");
}
NGRAPH_CHECK(target->get_output_size() == replacement_values.size());
@@ -285,7 +285,7 @@ std::shared_ptr<Model> clone_ov_model(const Model& func, std::unordered_map<Node
for (shared_ptr<Node> node : func.get_results()) {
auto result = ov::as_type_ptr<op::v0::Result>(node_map.at(node.get()));
if (!result) {
throw ngraph::ngraph_error("Results should be of type op::Result");
OPENVINO_THROW("Results should be of type op::Result");
}
cloned_results.push_back(result);
}
@@ -439,7 +439,7 @@ pair<shared_ptr<ngraph::op::Result>, shared_ptr<ngraph::op::Parameter>> ngraph::
const shared_ptr<Node>& src_node,
const shared_ptr<Node>& dst_node) {
if (src_node->get_output_size() != 1) {
throw ngraph_error("Multiple output per op not supported in graph partition yet.");
OPENVINO_THROW("Multiple output per op not supported in graph partition yet.");
}
// Make parameter node
+1 -1
View File
@@ -39,7 +39,7 @@ OV_CC_DOMAINS(ov_opset);
#elif defined(SELECTIVE_BUILD)
# define OV_OP_SCOPE(region) \
if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(ov_op, _, region)) == 0) \
throw ngraph::ngraph_error(std::string(OV_PP_TOSTRING(OV_PP_CAT3(ov_op, _, region))) + " is disabled!")
OPENVINO_THROW(std::string(OV_PP_TOSTRING(OV_PP_CAT3(ov_op, _, region))) + " is disabled!")
# define REGISTER_OP(opset_name, op_name)
# define INSERT_OP(opset_name, op_name, op_namespace) \
if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT4(ov_opset_, opset_name, _, op_name)) == 1) \
+7 -1
View File
@@ -26,6 +26,12 @@
using namespace std;
void ov::NodeValidationFailure::create(const CheckLocInfo& check_loc_info,
const Node* node,
const std::string& explanation) {
throw ov::NodeValidationFailure(make_what(check_loc_info, node_validation_failure_loc_string(node), explanation));
}
atomic<size_t> ov::Node::m_next_instance_id(0);
ov::Node::Node() = default;
@@ -417,7 +423,7 @@ const ov::element::Type& ov::Node::get_output_element_type(size_t i) const {
const ov::element::Type& ov::Node::get_element_type() const {
if (get_output_size() != 1) {
throw ngraph::ngraph_error("get_element_type() must be called on a node with exactly one output.");
OPENVINO_THROW("get_element_type() must be called on a node with exactly one output.");
}
return get_output_element_type(0);
}
+1 -1
View File
@@ -183,7 +183,7 @@ shared_ptr<Node> op::v3::Broadcast::clone_with_new_inputs(const OutputVector& ne
} else if (new_args.size() == 3) {
return make_shared<v3::Broadcast>(new_args.at(0), new_args.at(1), new_args.at(2), m_mode);
} else {
throw ngraph_error("Not supported number of Broadcast:v3 args");
OPENVINO_THROW("Not supported number of Broadcast:v3 args");
}
}
@@ -84,6 +84,6 @@ shared_ptr<Node> op::v6::CTCGreedyDecoderSeqLen::clone_with_new_inputs(const Out
m_classes_index_type,
m_sequence_length_type);
} else {
throw ngraph_error("Incorrect number of arguments");
OPENVINO_THROW("Incorrect number of arguments");
}
}
+1 -1
View File
@@ -105,7 +105,7 @@ shared_ptr<Node> op::v1::DeformablePSROIPooling::clone_with_new_inputs(const Out
m_trans_std,
m_part_size);
} else {
throw ngraph_error("Not supported number of DeformablePSROIPooling args");
OPENVINO_THROW("Not supported number of DeformablePSROIPooling args");
}
}
+1 -1
View File
@@ -132,6 +132,6 @@ shared_ptr<Node> op::v3::EmbeddingSegmentsSum::clone_with_new_inputs(const Outpu
new_args.at(4),
new_args.at(5));
} else {
throw ngraph_error("Incorrect number of arguments");
OPENVINO_THROW("Incorrect number of arguments");
}
}
+1 -1
View File
@@ -45,6 +45,6 @@ shared_ptr<Node> op::v3::EmbeddingBagOffsetsSum::clone_with_new_inputs(const Out
new_args.at(3),
new_args.at(4));
} else {
throw ngraph_error("Incorrect number of arguments");
OPENVINO_THROW("Incorrect number of arguments");
}
}
+1 -1
View File
@@ -26,6 +26,6 @@ shared_ptr<Node> op::v3::EmbeddingBagPackedSum::clone_with_new_inputs(const Outp
} else if (new_args.size() == 3) {
return make_shared<op::v3::EmbeddingBagPackedSum>(new_args.at(0), new_args.at(1), new_args.at(2));
} else {
throw ngraph_error("Incorrect number of arguments");
OPENVINO_THROW("Incorrect number of arguments");
}
}
+2 -2
View File
@@ -28,7 +28,7 @@ bool op::v0::Gelu::visit_attributes(AttributeVisitor& visitor) {
shared_ptr<Node> op::v0::Gelu::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v0_Gelu_clone_with_new_inputs);
if (new_args.size() != 1) {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return make_shared<op::v0::Gelu>(new_args.at(0));
}
@@ -78,7 +78,7 @@ bool op::v7::Gelu::visit_attributes(AttributeVisitor& visitor) {
shared_ptr<Node> op::v7::Gelu::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v7_Gelu_clone_with_new_inputs);
if (new_args.size() != 1) {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return make_shared<op::v7::Gelu>(new_args.at(0), m_approximation_mode);
}
+1 -1
View File
@@ -40,7 +40,7 @@ void op::v0::GRN::validate_and_infer_types() {
shared_ptr<Node> op::v0::GRN::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v0_GRN_clone_with_new_inputs);
if (new_args.size() != 1) {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return make_shared<GRN>(new_args.at(0), m_bias);
}
+1 -1
View File
@@ -141,6 +141,6 @@ shared_ptr<Node> op::v3::GRUCell::clone_with_new_inputs(const OutputVector& new_
get_clip(),
m_linear_before_reset);
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
+2 -2
View File
@@ -232,7 +232,7 @@ shared_ptr<Node> op::v0::LSTMCell::clone_with_new_inputs(const OutputVector& new
get_clip(),
m_input_forget);
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
@@ -401,6 +401,6 @@ shared_ptr<Node> op::v4::LSTMCell::clone_with_new_inputs(const OutputVector& new
get_activations_beta(),
get_clip());
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
+2 -2
View File
@@ -142,7 +142,7 @@ shared_ptr<Node> op::v0::LSTMSequence::clone_with_new_inputs(const OutputVector&
m_clip_threshold,
m_input_forget);
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
@@ -341,7 +341,7 @@ shared_ptr<Node> op::v5::LSTMSequence::clone_with_new_inputs(const OutputVector&
m_activations,
m_clip);
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
+1 -1
View File
@@ -82,7 +82,7 @@ AxisSet op::v0::NormalizeL2::get_reduction_axes() const {
shared_ptr<Node> op::v0::NormalizeL2::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v0_NormalizeL2_clone_with_new_inputs);
if (new_args.size() != 2) {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return make_shared<op::v0::NormalizeL2>(new_args.at(0), new_args.at(1), m_eps, m_eps_mode);
}
+4 -4
View File
@@ -105,7 +105,7 @@ void op::v8::RandomUniform::validate_and_infer_types() {
", max value: ",
max_val);
} else {
throw ngraph_error("Unsupported output type of RandomUniform: " + get_out_type().get_type_name());
OPENVINO_THROW("Unsupported output type of RandomUniform: " + get_out_type().get_type_name());
}
}
}
@@ -156,8 +156,8 @@ bool op::v8::RandomUniform::evaluate(const HostTensorVector& outputs, const Host
});
out_shape = out_shape_uint64.data();
} else {
throw ngraph_error("Unsupported type of out shape in RandomUniform operation: " +
inputs[0]->get_element_type().get_type_name());
OPENVINO_THROW("Unsupported type of out shape in RandomUniform operation: " +
inputs[0]->get_element_type().get_type_name());
}
element::Type_t t_out = get_out_type();
@@ -182,7 +182,7 @@ bool op::v8::RandomUniform::evaluate(const HostTensorVector& outputs, const Host
out = (char*)outputs[0]->get_data_ptr<const double>();
break;
default:
throw ngraph_error("Unsupported type of RandomUniform: " + get_out_type().get_type_name());
OPENVINO_THROW("Unsupported type of RandomUniform: " + get_out_type().get_type_name());
}
auto state = ngraph::runtime::reference::random_uniform(out_shape,
+1 -1
View File
@@ -165,7 +165,7 @@ bool op::v1::Reshape::evaluate_reshape(const HostTensorVector& outputs, const Ho
COMPUTE_OUT_SHAPE_CASE(u32, inputs[1], out_shape_val);
COMPUTE_OUT_SHAPE_CASE(u64, inputs[1], out_shape_val);
default:
throw ngraph_error("shape_pattern element type is not integral data type");
OPENVINO_THROW("shape_pattern element type is not integral data type");
}
std::vector<Dimension> reshape_pattern;
+1 -1
View File
@@ -175,6 +175,6 @@ shared_ptr<Node> op::v0::RNNCell::clone_with_new_inputs(const OutputVector& new_
get_activations_beta(),
get_clip());
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ size_t op::ShuffleChannels::get_zero_based_axis() const {
return ov::normalize_axis(this, m_axis, input_rank);
OPENVINO_SUPPRESS_DEPRECATED_END
} else {
throw ngraph_error("Cannot request zero-based axis with a input of unknown rank");
OPENVINO_THROW("Cannot request zero-based axis with a input of unknown rank");
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ bool ngraph::op::v0::SpaceToDepth::visit_attributes(AttributeVisitor& visitor) {
std::shared_ptr<Node> ov::op::v0::SpaceToDepth::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v0_SpaceToDepth_clone_with_new_inputs);
if (new_args.size() != 1) {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return std::make_shared<SpaceToDepth>(new_args.at(0), m_mode, m_blocksize);
}
+1 -1
View File
@@ -53,7 +53,7 @@ shared_ptr<Node> op::Squeeze::clone_with_new_inputs(const OutputVector& new_args
} else if (new_args.size() == 2) {
return make_shared<Squeeze>(new_args.at(0), new_args.at(1));
} else {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ bool op::v0::Unsqueeze::visit_attributes(AttributeVisitor& visitor) {
shared_ptr<Node> op::v0::Unsqueeze::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v0_Unsqueeze_clone_with_new_inputs);
if (new_args.size() != 2) {
throw ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return make_shared<Unsqueeze>(new_args.at(0), new_args.at(1));
}
+2 -1
View File
@@ -5,6 +5,7 @@
#include "ngraph/pattern/op/wrap_type.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "openvino/core/except.hpp"
using namespace std;
using namespace ngraph;
@@ -30,7 +31,7 @@ bool pattern::op::WrapType::match_value(Matcher* matcher,
NodeTypeInfo pattern::op::WrapType::get_wrapped_type() const {
if (m_wrapped_types.size() > 1) {
throw ngraph::ngraph_error("get_wrapped_type() called on WrapType with more than one type");
OPENVINO_THROW("get_wrapped_type() called on WrapType with more than one type");
}
return m_wrapped_types.at(0);
}
+2 -2
View File
@@ -350,7 +350,7 @@ vector<float> read_float_vector(shared_ptr<runtime::Tensor> tv) {
float_vec.push_back(static_cast<float>(value));
}
} else {
throw ngraph_error("Unsupported OpenVINO element type.");
OPENVINO_THROW("Unsupported OpenVINO element type.");
}
return float_vec;
@@ -426,7 +426,7 @@ vector<int64_t> read_index_vector(shared_ptr<runtime::Tensor> tv) {
index_vec.push_back(static_cast<int64_t>(value));
}
} else {
throw ngraph_error("Unsupported OpenVINO element type.");
OPENVINO_THROW("Unsupported OpenVINO element type.");
}
return index_vec;
+1 -1
View File
@@ -19,7 +19,7 @@ void FFTOp::validate_and_infer_types() {
std::shared_ptr<ngraph::Node> FFTOp::clone_with_new_inputs(const ngraph::OutputVector& new_args) const {
if (new_args.size() != 1) {
throw ngraph::ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return std::make_shared<FFTOp>(new_args.at(0), inverse);
}
+1 -1
View File
@@ -22,7 +22,7 @@ void Operation::validate_and_infer_types() {
//! [op:copy]
std::shared_ptr<ngraph::Node> Operation::clone_with_new_inputs(const ngraph::OutputVector& new_args) const {
if (new_args.size() != 1) {
throw ngraph::ngraph_error("Incorrect number of new arguments");
OPENVINO_THROW("Incorrect number of new arguments");
}
return std::make_shared<Operation>(new_args.at(0), add);
+1 -1
View File
@@ -37,7 +37,7 @@ public:
ControlDependencyOp(const OutputVector& args, const std::set<std::shared_ptr<Node>>& deps) : Op(args) {
if (args.size() == 0 && deps.size() == 0) {
throw ngraph_error("Expected some arguments or dependencies");
OPENVINO_THROW("Expected some arguments or dependencies");
}
for (auto& node : deps) {
+2 -2
View File
@@ -409,7 +409,7 @@ public:
*/
auto cnt = consumers(node.get());
if (node.use_count() != cnt + 7) {
throw ngraph::ngraph_error("Wrong number of consumers");
OPENVINO_THROW("Wrong number of consumers");
}
NodeVector nodes;
@@ -423,7 +423,7 @@ public:
*/
for (const auto& input_node : nodes) {
if (input_node.use_count() != consumers(input_node.get()) + 1) {
throw ngraph::ngraph_error("Wrong number of consumers");
OPENVINO_THROW("Wrong number of consumers");
}
}
return false;
+2 -2
View File
@@ -1977,7 +1977,7 @@ TEST(pre_post_process, exception_safety) {
.tensor()
.set_color_format(ColorFormat::NV12_TWO_PLANES);
p.input().preprocess().custom([](const Output<Node>& node) -> Output<Node> {
throw ngraph::ngraph_error("test error");
OPENVINO_THROW("test error");
});
p.build(), ov::AssertFailure);
@@ -1989,7 +1989,7 @@ TEST(pre_post_process, exception_safety) {
p.output(1) // This one is not
.postprocess()
.custom([](const Output<Node>& node) -> Output<Node> {
throw ngraph::ngraph_error("test error");
OPENVINO_THROW("test error");
});
p.build(), ngraph::ngraph_error);
EXPECT_EQ(f->get_parameters().size(), 2);
+1 -1
View File
@@ -26,7 +26,7 @@ static std::shared_ptr<Node> makeReduceOp(const ReduceParams& p, bool axes_as_pa
in_axes = make_shared<op::Parameter>(p.axes_et, p.axes_ps);
} else {
if (shape_size(p.axes_ps) != p.axes.size()) {
throw ngraph_error("Axes shape does not match with axes elements");
OPENVINO_THROW("Axes shape does not match with axes elements");
}
in_axes = make_shared<op::Constant>(p.axes_et, p.axes_ps, p.axes);
}
@@ -14,36 +14,52 @@ namespace ov {
namespace frontend {
class FRONTEND_API GeneralFailure : public AssertFailure {
public:
GeneralFailure(const CheckLocInfo& check_loc_info, const std::string& context, const std::string& explanation)
: AssertFailure(check_loc_info, "FrontEnd API failed with GeneralFailure: " + context, explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
protected:
explicit GeneralFailure(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
class FRONTEND_API InitializationFailure : public AssertFailure {
public:
InitializationFailure(const CheckLocInfo& check_loc_info,
const std::string& context,
const std::string& explanation)
: AssertFailure(check_loc_info, "FrontEnd API failed with InitializationFailure: " + context, explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
protected:
explicit InitializationFailure(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
class FRONTEND_API OpValidationFailure : public AssertFailure {
public:
OpValidationFailure(const CheckLocInfo& check_loc_info, const std::string& context, const std::string& explanation)
: AssertFailure(check_loc_info, "FrontEnd API failed with OpValidationFailure: " + context, explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
protected:
explicit OpValidationFailure(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
class FRONTEND_API OpConversionFailure : public AssertFailure {
public:
OpConversionFailure(const CheckLocInfo& check_loc_info, const std::string& context, const std::string& explanation)
: AssertFailure(check_loc_info, "FrontEnd API failed with OpConversionFailure: " + context, explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
protected:
explicit OpConversionFailure(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
class FRONTEND_API NotImplementedFailure : public AssertFailure {
public:
NotImplementedFailure(const CheckLocInfo& check_loc_info,
const std::string& context,
const std::string& explanation)
: AssertFailure(check_loc_info, "FrontEnd API failed with NotImplementedFailure: " + context, explanation) {}
[[noreturn]] static void create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation);
protected:
explicit NotImplementedFailure(const std::string& what_arg) : ov::AssertFailure(what_arg) {}
};
/// \brief Macro to check whether a boolean condition holds.
+40
View File
@@ -0,0 +1,40 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/frontend/exception.hpp"
void ov::frontend::GeneralFailure::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::frontend::GeneralFailure(
make_what(check_loc_info, "FrontEnd API failed with GeneralFailure: " + context_info, explanation));
}
void ov::frontend::InitializationFailure::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::frontend::InitializationFailure(
make_what(check_loc_info, "FrontEnd API failed with InitializationFailure: " + context_info, explanation));
}
void ov::frontend::OpValidationFailure::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::frontend::OpValidationFailure(
make_what(check_loc_info, "FrontEnd API failed with OpValidationFailure: " + context_info, explanation));
}
void ov::frontend::OpConversionFailure::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::frontend::OpConversionFailure(
make_what(check_loc_info, "FrontEnd API failed with OpConversionFailure: " + context_info, explanation));
}
void ov::frontend::NotImplementedFailure::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
throw ov::frontend::NotImplementedFailure(
make_what(check_loc_info, "FrontEnd API failed with NotImplementedFailure: " + context_info, explanation));
}
@@ -22,8 +22,10 @@ namespace onnx_import {
namespace error {
namespace node {
struct UnknownAttribute : ngraph_error {
OPENVINO_SUPPRESS_DEPRECATED_START
explicit UnknownAttribute(const std::string& node, const std::string& name)
: ngraph_error{"Node (" + node + "): unknown attribute \'" + name + "\'"} {}
OPENVINO_SUPPRESS_DEPRECATED_END
};
} // namespace node
@@ -27,9 +27,11 @@ using AttributeProto_AttributeType = decltype(ONNX_NAMESPACE::AttributeProto{}.t
namespace error {
namespace attribute {
namespace detail {
OPENVINO_SUPPRESS_DEPRECATED_START
struct Attribute : ngraph_error {
Attribute(const std::string& msg, AttributeProto_AttributeType type) : ngraph_error{msg} {}
};
OPENVINO_SUPPRESS_DEPRECATED_END
} // namespace detail
@@ -375,7 +375,7 @@ OutputVector Graph::make_ng_nodes(const Node& onnx_node) {
throw;
} catch (const std::exception& exc) {
std::string msg_prefix = error::detail::get_error_msg_prefix(onnx_node);
throw ngraph_error(msg_prefix + ":\n" + std::string(exc.what()));
OPENVINO_THROW(msg_prefix + ":\n" + std::string(exc.what()));
} catch (...) {
std::string msg_prefix = error::detail::get_error_msg_prefix(onnx_node);
// Since we do not know anything about current exception data type we can only
@@ -22,7 +22,7 @@ Output<ngraph::Node> GraphCache::get_node(const std::string& name) const {
try {
return m_graph_cache_map.at(name);
} catch (const std::out_of_range&) {
throw ngraph_error(name + " node not found in graph cache");
OPENVINO_THROW(name + " node not found in graph cache");
}
}
@@ -29,6 +29,7 @@ using TensorProto_DataType = decltype(ONNX_NAMESPACE::TensorProto{}.data_type())
namespace error {
namespace tensor {
OPENVINO_SUPPRESS_DEPRECATED_START
struct invalid_data_type : ngraph_error {
explicit invalid_data_type(TensorProto_DataType type) : ngraph_error{"invalid data type"} {}
};
@@ -56,6 +57,7 @@ struct segments_unsupported : ngraph_error {
struct shape_doesnt_match_data_size : ngraph_error {
shape_doesnt_match_data_size() : ngraph_error{"tensor shape doesn't match data size"} {}
};
OPENVINO_SUPPRESS_DEPRECATED_END
} // namespace tensor
} // namespace error

Some files were not shown because too many files have changed in this diff Show More