|
5 | 5 | # -------------------------------------------------------------------------- |
6 | 6 |
|
7 | 7 | import re |
| 8 | +import warnings |
8 | 9 | from distutils.version import StrictVersion |
9 | 10 | from ...proto import onnx |
10 | 11 | from ...proto import helper |
@@ -649,17 +650,31 @@ def convert_topology(topology, model_name, doc_string, targeted_onnx): |
649 | 650 | other_outputs[variable.raw_name] = variable |
650 | 651 |
|
651 | 652 | # Add roots the graph according to their order in the original model |
| 653 | + invalid_name = [] |
652 | 654 | for name in topology.raw_model.input_names: |
| 655 | + # Check input naming convention |
| 656 | + input_name = name.replace('_', '') |
| 657 | + if input_name and (input_name[0].isdigit() or (not input_name.isalnum())): |
| 658 | + invalid_name.append(name) |
653 | 659 | if name in tensor_inputs: |
654 | 660 | container.add_input(tensor_inputs[name]) |
| 661 | + if invalid_name: |
| 662 | + warnings.warn('Some input names are not compliant with ONNX naming convention: %s' % invalid_name) |
655 | 663 | for name in topology.raw_model.input_names: |
656 | 664 | if name in other_inputs: |
657 | 665 | container.add_input(other_inputs[name]) |
658 | 666 |
|
659 | 667 | # Add leaves the graph according to their order in the original model |
| 668 | + invalid_name = [] |
660 | 669 | for name in topology.raw_model.output_names: |
| 670 | + # Check output naming convention |
| 671 | + output_name = name.replace('_', '') |
| 672 | + if output_name and (output_name[0].isdigit() or (not output_name.isalnum())): |
| 673 | + invalid_name.append(name) |
661 | 674 | if name in tensor_outputs: |
662 | 675 | container.add_output(tensor_outputs[name]) |
| 676 | + if invalid_name: |
| 677 | + warnings.warn('Some output names are not compliant with ONNX naming convention: %s' % invalid_name) |
663 | 678 | for name in topology.raw_model.output_names: |
664 | 679 | if name in other_outputs: |
665 | 680 | container.add_output(other_outputs[name]) |
|
0 commit comments