microsoft / DirectML

DirectML is a high-performance, hardware-accelerated DirectX 12 library for machine learning. DirectML provides GPU acceleration for common machine learning tasks across a broad range of supported hardware and drivers, including all DirectX 12-capable GPUs from vendors such as AMD, Intel, NVIDIA, and Qualcomm.
MIT License
2.21k stars 295 forks source link

About DirectML & DirectCompute #383

Open Looong01 opened 1 year ago

Looong01 commented 1 year ago

I notice that "Or you could use HLSL to write a compute shader, perhaps to implement a physics simulation. However, if for example you're inclined to write your own convolution operator (for image processing) as HLSL in a compute shader, then you'll get better performance in that scenario if you use Direct Machine Learning (DirectML) instead." here.

  1. Does DirectML have all the characteristics of DirectCompute?
  2. Are all the APIs and functions in DirectCompute compatible with DirectML?
  3. What are the differences between DirectCompute and DirectML?
  4. In which situation should I use DirectCompute? When should I use DirectML?
BytePetter commented 1 year ago

Push, because I need answers to these questions, too.

jstoecker commented 1 year ago

Background:

Your questions:

  1. Not sure how to answer this, because DirectML uses compute shaders. DirectML is not a superset or replacement for compute shaders, which should hopefully be more clear from background.
  2. DirectML is compatible with Direct3D 12 and hand-written compute shaders. You can mix both types of work into the same D3D12 command lists, for example.
  3. Hopefully explained earlier.
  4. This is similar to asking when you should use an API like std::sort instead of writing your own sorting algorithm. You're encouraged to use the DirectML APIs if they fit your use case, but it can't cover all possible cases.