Languages
ONNX Runtime
When to use ONNX Runtime with ROCm or MIGraphX instead of calling MIGraphX directly.
ONNX Runtime is useful when your application already uses ONNX Runtime APIs and you want a GPU execution provider. Direct MIGraphX is usually better when you want full control over compile, save, load, and runtime execution in a native AMD backend.
Decision Table
| Need | Prefer |
|---|---|
| Existing ONNX Runtime application | ONNX Runtime provider |
| Native C++ service with saved compiled artifacts | Direct MIGraphX |
| Fast model compatibility smoke test | migraphx-driver |
| Multi-provider fallback in one runtime | ONNX Runtime |
| TensorRT-style backend abstraction | Direct MIGraphX |
Python Shape
The exact provider names and options depend on your installed ONNX Runtime build. A typical provider-style setup looks like this:
import onnxruntime as ort
session = ort.InferenceSession(
"model.onnx",
providers=[
"MIGraphXExecutionProvider",
"ROCMExecutionProvider",
"CPUExecutionProvider",
],
)
inputs = {session.get_inputs()[0].name: input_array}
outputs = session.run(None, inputs)Check ort.get_available_providers() on the target machine before assuming a provider exists:
import onnxruntime as ort
print(ort.get_available_providers())C++ Shape
#include <onnxruntime_cxx_api.h>
int main()
{
Ort::Env env{ORT_LOGGING_LEVEL_WARNING, "app"};
Ort::SessionOptions options;
// Provider append calls depend on the ONNX Runtime build.
Ort::Session session{env, "model.onnx", options};
}Use direct MIGraphX if your application needs saved MIGraphX programs or MIGraphX-specific compile options.