Fix sign-compare warnings in ONNX FE (#16125)
* editor.cpp * fix scan.cpp * fix place.cpp * fix tensor_external_data.cpp * fix editor.cpp * remove no-sign * add sign-comare in os_flags.cmake * fix place.cpp * fix tensor_external_data.cpp * remove sign-compare * fix onnx_transformations.cpp * fixed get_input_port + refactor --------- Co-authored-by: haiqi <haiqi.pan@intel.com>
This commit is contained in:
1 parent
4d3dcfc5d4
commit
e77adca01f
6 files changed
+19
-23
No files matched your search
@@ -2,9 +2,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ie_add_compiler_flags(-Wno-sign-compare)
|
||||
endif()
|
||||
|
||||
add_subdirectory(onnx_common)
|
||||
add_subdirectory(frontend)
|
||||
|
||||
@@ -214,7 +214,7 @@ void graph_topological_sort(GraphProto* graph) {
|
||||
std::multimap<std::string, const NodeProto*> output_name_to_node;
|
||||
GraphProto result;
|
||||
|
||||
for (size_t i = 0; i < graph->node().size(); ++i) {
|
||||
for (int i = 0; i < graph->node().size(); ++i) {
|
||||
for (const auto& output_name : graph->node(i).output()) {
|
||||
output_name_to_node.emplace(output_name, graph->mutable_node(static_cast<int>(i)));
|
||||
}
|
||||
@@ -578,11 +578,11 @@ void onnx_editor::ONNXModelEditor::set_tensor_name(const std::string& current_na
|
||||
if (const auto value_info = find_graph_value_info(*graph, current_name))
|
||||
*value_info->mutable_name() = new_name;
|
||||
|
||||
for (size_t i = 0; i < graph->node().size(); ++i) {
|
||||
for (int i = 0; i < graph->node().size(); ++i) {
|
||||
const auto node = graph->mutable_node(static_cast<int>(i));
|
||||
|
||||
bool output_found = false;
|
||||
for (size_t j = 0; j < node->output().size(); ++j)
|
||||
for (int j = 0; j < node->output().size(); ++j)
|
||||
if (node->output(static_cast<int>(j)) == current_name) {
|
||||
*node->mutable_output(static_cast<int>(j)) = new_name;
|
||||
output_found = true;
|
||||
@@ -591,7 +591,7 @@ void onnx_editor::ONNXModelEditor::set_tensor_name(const std::string& current_na
|
||||
if (output_found)
|
||||
continue;
|
||||
|
||||
for (size_t j = 0; j < node->input().size(); ++j)
|
||||
for (int j = 0; j < node->input().size(); ++j)
|
||||
if (node->input(static_cast<int>(j)) == current_name)
|
||||
*node->mutable_input(static_cast<int>(j)) = new_name;
|
||||
}
|
||||
@@ -623,7 +623,7 @@ void onnx_editor::ONNXModelEditor::clear_nodes_name(const std::string& name) {
|
||||
|
||||
m_pimpl->m_is_mapper_updated = false;
|
||||
|
||||
for (size_t i = 0; i < graph->node().size(); ++i) {
|
||||
for (int i = 0; i < graph->node().size(); ++i) {
|
||||
const auto node = graph->mutable_node(static_cast<int>(i));
|
||||
if (node->has_name() && node->name() == name)
|
||||
node->clear_name();
|
||||
@@ -647,7 +647,7 @@ void onnx_editor::ONNXModelEditor::set_name_for_dimension(const std::string& nod
|
||||
|
||||
const auto set_dim_param = [&shape_dim_index, &dim_name](ValueInfoProto* tensor) {
|
||||
const auto shape = tensor->mutable_type()->mutable_tensor_type()->mutable_shape();
|
||||
auto shape_dim_size = shape->dim_size();
|
||||
size_t shape_dim_size = shape->dim_size();
|
||||
|
||||
for (; shape_dim_size <= shape_dim_index; ++shape_dim_size)
|
||||
add_dim_to_onnx_shape(Dimension::dynamic(), *shape);
|
||||
|
||||
@@ -45,7 +45,7 @@ OutputVector scan_to_tensor_iterator(const OutputVector& node_inputs,
|
||||
// but in ONNX Scan the slice of input can has one dimension less,
|
||||
// so the parameter needs to have aligned rank with 1 at sliced axis,
|
||||
// and then squeezed to restore original shape.
|
||||
for (size_t i = 0; i < num_scan_inputs; ++i) {
|
||||
for (int64_t i = 0; i < num_scan_inputs; ++i) {
|
||||
const auto in_idx = num_initial_values + i;
|
||||
auto axis = scan_input_axes[i];
|
||||
const auto axis_node = default_opset::Constant::create(element::i64, Shape{1}, {axis});
|
||||
@@ -79,7 +79,7 @@ OutputVector scan_to_tensor_iterator(const OutputVector& node_inputs,
|
||||
tensor_iterator->set_function(ti_body);
|
||||
|
||||
// Set slicing for Scan (TensorIterator) inputs
|
||||
for (size_t i = 0; i < num_scan_inputs; ++i) {
|
||||
for (int64_t i = 0; i < num_scan_inputs; ++i) {
|
||||
const auto in_idx = num_initial_values + i;
|
||||
const auto axis = ov::normalize_axis(node_description,
|
||||
scan_input_axes[i],
|
||||
|
||||
@@ -267,7 +267,8 @@ ov::frontend::Place::Ptr PlaceOp::get_output_port() const {
|
||||
|
||||
ov::frontend::Place::Ptr PlaceOp::get_output_port(int output_port_index) const {
|
||||
check_if_valid();
|
||||
if (output_port_index < m_editor->get_output_ports(m_node).size()) {
|
||||
const int out_ports_number = static_cast<int>(m_editor->get_output_ports(m_node).size());
|
||||
if (output_port_index < out_ports_number) {
|
||||
return std::make_shared<PlaceOutputEdge>(
|
||||
m_editor->find_output_edge(m_node, onnx_editor::EditorOutput{output_port_index}),
|
||||
m_editor);
|
||||
@@ -295,7 +296,8 @@ ov::frontend::Place::Ptr PlaceOp::get_input_port() const {
|
||||
|
||||
ov::frontend::Place::Ptr PlaceOp::get_input_port(int input_port_index) const {
|
||||
check_if_valid();
|
||||
if (input_port_index < m_editor->get_input_ports(m_node).size()) {
|
||||
const int in_ports_number = static_cast<int>(m_editor->get_input_ports(m_node).size());
|
||||
if (input_port_index < in_ports_number) {
|
||||
return std::make_shared<PlaceInputEdge>(
|
||||
m_editor->find_input_edge(m_node, onnx_editor::EditorInput{input_port_index}),
|
||||
m_editor);
|
||||
@@ -315,8 +317,8 @@ ov::frontend::Place::Ptr PlaceOp::get_input_port(const std::string& input_name)
|
||||
|
||||
std::vector<ov::frontend::Place::Ptr> PlaceOp::get_consuming_ports() const {
|
||||
std::vector<ov::frontend::Place::Ptr> consuming_ports;
|
||||
const auto out_ports_size = m_editor->get_output_ports(m_node).size();
|
||||
for (int out_idx = 0; out_idx < out_ports_size; ++out_idx) {
|
||||
const auto out_ports_number = m_editor->get_output_ports(m_node).size();
|
||||
for (size_t out_idx = 0; out_idx < out_ports_number; ++out_idx) {
|
||||
auto consuming_ops_out = get_output_port(out_idx)->get_consuming_ports();
|
||||
consuming_ports.insert(consuming_ports.end(), consuming_ops_out.begin(), consuming_ops_out.end());
|
||||
}
|
||||
|
||||
@@ -44,18 +44,15 @@ std::string TensorExternalData::load_external_data(const std::string& model_dir)
|
||||
#endif
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (external_data_stream.fail())
|
||||
throw error::invalid_external_data{*this};
|
||||
|
||||
auto filesize = external_data_stream.tellg();
|
||||
if (filesize == -1) {
|
||||
if (external_data_stream.fail()) {
|
||||
throw error::invalid_external_data{*this};
|
||||
}
|
||||
if (m_offset + m_data_length > filesize) {
|
||||
const uint64_t file_size = static_cast<uint64_t>(external_data_stream.tellg());
|
||||
if (m_offset + m_data_length > file_size) {
|
||||
throw error::invalid_external_data{*this};
|
||||
}
|
||||
|
||||
uint64_t read_data_length = m_data_length > 0 ? m_data_length : static_cast<uint64_t>(filesize) - m_offset;
|
||||
uint64_t read_data_length = m_data_length > 0 ? m_data_length : static_cast<uint64_t>(file_size) - m_offset;
|
||||
|
||||
// default value of m_offset is 0
|
||||
external_data_stream.seekg(m_offset, std::ios::beg);
|
||||
|
||||
@@ -38,7 +38,7 @@ bool after_func_expand_name_comp(std::string lhs, std::string rhs) {
|
||||
auto cut_length = -1;
|
||||
|
||||
auto founded_hex = 0;
|
||||
for (int i = 0; i < name.size(); ++i) {
|
||||
for (size_t i = 0; i < name.size(); ++i) {
|
||||
if (is_hex_symbol(name[i])) {
|
||||
++founded_hex;
|
||||
if (cut_begin == -1) {
|
||||
|
||||
Reference in new issue
Block a user