KhronosGroup / NNEF-Tools

The NNEF Tools repository contains tools to generate and consume NNEF documents
https://www.khronos.org/nnef
222 stars 58 forks source link

ONNX to NNEF: NameError: name 'split' is not defined #161

Closed Christof23 closed 1 year ago

Christof23 commented 1 year ago

Hi, I'm getting a Could not evaluate attribute 'ratios' while converting operator 'Split'; NameError: name 'split' is not defined error when converting a yolov5s.onnx model to NNEF format. Any suggestions about how to fix this issue would be greatly appreciated.

gyenesvi commented 1 year ago

Hi, it seems that the newer versions of the Split operator in ONNX can also take the split ratios as a dynamic tensor instead of a static attribute. I have pushed a fix for this case, can you try again after pulling the latest code? BTW, exporting the ONNX model with an older opset version could also help in such cases.

Christof23 commented 1 year ago

Hi @gyenesvi, thank you very much for your help with this issue.

I've updated my local repo which fixes the split error. The model now exports to a directory, but returns a Read-only file system: '/model.24' message. When I import the tgz compressed nnef model into tract I get a Error: Resource graph.nnef was not found in the model, although in the actual directory the graph.nnef file is present.

gyenesvi commented 1 year ago

Hmm, I have no idea what that read-only issue could be, is '/model.24' one of the weights? Do you get this error during conversion? And what do you use to import the model? The python package in this repo, or something else? Did you try without tgz compression? Does the graph.nnef have seemingly proper contents inside if you open with a text editor?

Christof23 commented 1 year ago

The graph.nnef file looks reasonable (from my very limited knowledge) and has references to model.24 which start to appear in the last few variable assignments in the file, e.g.:

variable122 = variable<scalar>(shape = [1, 3, 80, 80, 2], label = '/model.24/Constant_6');

I'm not sure what this means, but they appear in the original onnx file. This variable122 occurs just after a load of conv/sigmoid/concat operations. I've attached the graph.nnef file for reference.

I'm reading in the nnef file in a similar fashion to this example. Without tgz compression still returns the same graph.nnef not found message.

gyenesvi commented 1 year ago

Indeed the nnef file looks reasonable. But did you get the readonly error while conerting or while reading it in? That reader you reference is not part of this toolset, so I cannot help with that one unfortunately. You could try reading back the NNEF model with these python tools to check if it works. For example you could just try to conver it back to ONNX or even just to NNEF, you should just get the same file again but tests the reader.

gyenesvi commented 1 year ago

@Christof23 any update on this? Can I close it?