Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

bug in layer graph construction #133

Open
Hyunseok-Kim0 opened this issue Nov 9, 2022 · 1 comment
Open

bug in layer graph construction #133

Hyunseok-Kim0 opened this issue Nov 9, 2022 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@Hyunseok-Kim0
Copy link

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, PyTorch, ONNX, TensorFlow

Download URL for ONNX / OpenVINO IR

any big enough openvino file can be target of this bug.

Convert Script

used same command from this repo.

Description

for layer in layers:
if layer.attrib['id'] == from_layer:
output_layer_ports = layer.find('output')
if len(output_layer_ports) >= 2 and layer.attrib['type'] not in ignore_garbage_output_op_types:
flg = 'not_found'
for key in tf_edges.keys():
if to_layer in key and from_layer in tf_edges[key] and '{}:{}'.format(from_layer, from_layer_port) not in tf_edges[key]:
tf_edges[key].append('{}:{}'.format(from_layer, from_layer_port))
flg = 'found'
try:
tf_edges[key].remove(from_layer)
except:
pass
if flg == 'not_found':
tf_edges.setdefault(to_layer, []).append('{}:{}'.format(from_layer, from_layer_port))
if to_layer not in added_key_list:
added_key_list.append(to_layer)
else:
if to_layer not in added_key_list:
tf_edges.setdefault(to_layer, []).append(from_layer)
added_key_list.append(to_layer)
else:
flg = 'not_found'
for key in tf_edges.keys():
if to_layer in key and from_layer in tf_edges[key]:
flg = 'found'
break
if flg == 'not_found':
tf_edges.setdefault(to_layer, []).append(from_layer)
break

I guess the codes in line number 559 and 579 is used to find connected layer with specific layer number and port number. The key and value from dictionary are compared in those lines.
However, it looks to_layer in key is not proper way to compare the layer number since key is string. if to_layer is '23' and key is '236', it will return true. After that, some layers will not be recorded in tf_edges, so the conversion will fail.
I am not sure if the key can be different shape or type, but that line caused problem in my case. After I changed that line to to_layer == key, the problem is gone.

maybe this is main cause of index list out of range error around line 586~593 like #127 (comment)

# The following loop sorts tf_edges in ascending order by port
for to_layer, from_layer_ports in concat_port_list.items():
temp_sorted_tf_edge = []
# from_layer_ports = [from_layer_id:port, from_layer_id:port, from_layer_id:port, ...]
ports = [p.split(':')[1] for p in from_layer_ports]
for idx, port in enumerate(ports):
temp_sorted_tf_edge.append(tf_edges[to_layer][ports.index(str(idx))])
tf_edges[to_layer] = temp_sorted_tf_edge

Relevant Log Output

.

Source code for simple inference testing code

No response

@PINTO0309 PINTO0309 added bug Something isn't working enhancement New feature or request labels Nov 9, 2022
@PINTO0309
Copy link
Owner

This is the first time I have received such a detailed and thorough proposal. Thank you very much.
I will try your suggested modifications in the next update. :)

Incidentally, openvino2tensorflow is a tool I dared to start making to compensate for the low conversion performance of onnx-tensorflow, but I made it blindly without much ML knowledge. Thus, the abundance of optimization features is proportional to the low quality of my program.

I myself recognize that the workload required of users is very high due to the abundance of features and error handling. Thus, I have recently started building a new tool that incorporates all of my 2-3 years of model conversion experience.
https://github.com/PINTO0309/onnx2tf
It is probably the most efficient optimization tool among the various tools I have created, and yet it has the lowest conversion error rate.

Instead of updating openvino2tensorflow a little less frequently using my private work time, I try to devote as much time as possible to updating onnx2tf. If you are interested, give it a try, I think it is easier than openvino2tensorflow.

Again, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants