xla icon indicating copy to clipboard operation
xla copied to clipboard

Porting XLA to different backends.

Open abhaskumarsinha opened this issue 1 year ago • 0 comments
trafficstars

Hello,

I'm very new to the XLA project, so pardon my ignorance here. I'm trying to learn more about the project, optimizations, and their interactions with the hardware. The code everywhere seems well-written and properly documented. The project seems very vast that has been maintained through the effort of tremendous volunteers and not so easy to debug language like Python, so it's very easy to get lost.

Here's what I've been able to gather about the project. The DL frameworks seem to construct graphs of their Deep Learning model prior to the computation, where these graphs with their tensor computations get optimized by XLA-like tools called - Linear Algebra Compilers.

Now, XLA uses HLO to perform such optimizations to produce latent computational information which is executed by CPU/GPU/TPU into their desired computational formats.


My goal here was to learn how backends of such can be ported swiftly to here are some of my learnings:

  1. The whole project depends upon the ecosystem of LLVM compilers.
  2. The LLVM Compilers need to be set and XLA::Compiler and XLA::CPUCompiler, XLA::GPUCompiler needs to be re-written accordingly according to the target platform. These correspond to the files here: xla\service\compiler.h, xla\service\cpu\cpu_compiler.h and similarly for GPU/TPU.
  3. In case, if someone fails to port LLVM and LLVM libraries, then things get ugly. All all the four header files mentioned here would require porting, knowing, executor contains stream.h and stream_executor_pimpl.h.

Right?


Also in case, please clarify do they need to ONLY adapt these header files into their new hardware (which doesn't seems so) OR other header files that have been additionally included into those header files too? (that'd be a bit of effort!). For example - if I manage to get LLVM into specific target hardware and now I seek to port my code into that particular hardware, to get that, do I need to ONLY start porting xla\service\compiler.h, xla\service\cpu\cpu_compiler.h OR every header file that has been included in those headers? (which amounts to 18+16 = 34 header files in total in number?)


In case there is any error in understanding the concept, or any disparity in my explanation do please point that out.

Best Regards, Abhas Kumar Sinha

abhaskumarsinha avatar May 15 '24 16:05 abhaskumarsinha