Skip to content

DirectML inference produces incorrect results #327

@tutryx

Description

@tutryx

Hello,
I trained the D-FINE nano model on a custom dataset and exported it to ONNX using the provided export_onnx.py.

Inference results:

  • ✅ CPU execution provider → correct
  • ✅ CUDA execution provider → correct
  • ❌ DirectML execution provider → extremely low confidences (~0.05), incorrect bounding box sizes and some operations fallback to the CPU

I used the provided C++ ONNX Runtime example (onnxExample.cpp), adding DirectML with:

OrtGetApiBase()->GetApi(ORT_API_VERSION)->GetExecutionProviderApi("DML", ORT_API_VERSION, reinterpret_cast<const void**>(&m_dmlApi));  
m_dmlApi->SessionOptionsAppendExecutionProvider_DML(session_options, 0);

What I tried:

  • Disabled ONNX Runtime optimizations → same wrong results.
  • Exported with fixed input size (no dynamic axes), opset 17 → model runs fully on GPU (no CPU fallback), still wrong results.
  • Exported without postprocessing → same issue.

So far it looks like DirectML produces incorrect outputs even though CPU/CUDA inference works fine.

CPU / CUDA
Image

DirectML
Image

Is this a known issue with the model/export, or with ONNX Runtime + DirectML?
Would other models as RF-DETR or DT-DETR work with DirectML?

Any guidance would be appreciated.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions