ngraph icon indicating copy to clipboard operation
ngraph copied to clipboard

Question: Is the LLVM necessary in this project?

Open xiezhq-hermann opened this issue 8 years ago • 8 comments

Thanks for your great project, I roughly read the code and I'll appreciate if you could help me with these questions:

  • What's your main purpose to adapt the LLVM in this project, it seems that you didn't leverage the LLVM IR to do the optimization, for example, the CPU backend generate the C code and let Clang/LLVM compile it and link the OPs. In other word, any other compiler backend would be qualified either, right?
  • As far as my understanding, this project actually focuses on rewriting the computation graph based on the knowledge of OP nodes (since the major ops are hand-written and classified). Am I right?
  • So, what're your opinions towards leveraging LLVM further, it's reasonable for Intel to not care about more hardware platform support, but is there any other plan?
  • As you might know, some project like TVM adapt a different routine, in addition to graph level IR like nGraph, there is a lower level Halide IR to help scheduling the computation inside an OP, and then generate LLVM IR, finally generate the target dependent machine code. Will you take some similar ideas into the nGraph project?

Thank you very much! The code of this project is very concise and elegant, I'll try to contribute if there're some proper chances for me.

xiezhq-hermann avatar Oct 07 '18 16:10 xiezhq-hermann

We focused at the tensor operation level, trying to give existing tools an additional advantage from the larger context available. There are investigations in extending compilation down closer to the hardware, such as with halide, tvm, and plaidml.

diyessi avatar Oct 07 '18 21:10 diyessi

Thanks for your reply! What I mean “rewrite the graph” includes the tensor operations either. I think I got your words. Could you please talk more about the first question? It seems the compilers other than Clang/LLVM would be pretty qualified either, right?

xiezhq-hermann avatar Oct 08 '18 00:10 xiezhq-hermann

Originally we were primarily generating C++, which had the advantage of making it easier to see what was going on, and this was what clang was for, but it has turned out to be slow to compile the generated code (templates, etc.) and have a few other issues as well. The "DEX" approach working well at the moment.

diyessi avatar Oct 08 '18 16:10 diyessi

LLVM has the advantage of being a "set of compiler libraries" allowing you to easily integrate any or all functions of a compiler into your code. Also, the ngraph developers have experience integrating LLVM into projects so it was an easy decision to use it over other compilers.

rkimballn1 avatar Oct 08 '18 16:10 rkimballn1

Thanks for your insightful reply! And sorry for my verbose, but I want to confirm these questions more clear:

  1. For the "DEX" approach here, have you found anything that other compiler (like gcc or Intel C compiler) can't do but must Clang/LLVM?
  2. What if register your nGraph IR to LLVM IR for further codegen (though it might be tedious and pointless)?
  3. What's your future plan of this project except more frontend support to various frameworks? Thank you very much!

xiezhq-hermann avatar Oct 08 '18 16:10 xiezhq-hermann

  1. DEX is something like kernel interpretation, so no compilation at runtime. I think only llvm has support for embedding the compiler in a program and compiling additional code in memory,
  2. Tensors are a lot different from scalars.
  3. More devices, eager execution, compilation to something like a shared library are a few things.

diyessi avatar Oct 08 '18 17:10 diyessi

Thank you very much! I refered your code for the DEX approach but not very clear about it, is there any supplemental reference for it?

xiezhq-hermann avatar Oct 08 '18 17:10 xiezhq-hermann

We added some more detail on that approach in some documentation that went out with our release at the end of last year: https://ngraph.nervanasys.com/docs/latest/project/about.html . If you have other questions, please address them in a separate issue, thanks.

indie avatar Jan 18 '19 14:01 indie