Support non-topologically sorted graphs
While most graphs we encounter are topologically sorted, and while ONNX IR spec specifies that to be the case, for compliance, ( see https://github.com/onnx/onnx/blob/main/docs/IR.md#graphs ), however, we do encounter non topologically sorted graphs on occasion, and furthermore both ORT and Netron seem to support them.
As we build the migraphx IR, we can add nodes before they are defined (and keep a list of undefined ops)... eventually they will be defined! Each new node we encounter, we will first check to see if it is in the "undefined" list.
We use the order in the onnx files to ensure that the order is consistent with the onnx file:
https://github.com/ROCm/AMDMIGraphX/pull/479
For invalid onnx file, we can write a python script to sort them or we could have a flag to pass to the onnx parser that will sort the nodes first, but we dont want that flag enabled by default because it can change the order of the nodes if they are already sorted.