I am using XLA AOT to compile my model (using tf_library macro). All works well and the .h and object files are generated. Now I would like to get LLVM IR that was internally generated by tfcompile but I can not find a way to do so. Neither I can find any flag for the tfcompile that would allow me to get the LLVM IR.
Is there anyway to get the LLVM when using XLA AOT and tfcompile?
Yes I tried that, but did not work. It seems that that may work when you are using JIT (not AOT) in your tensorflow program (python), at least that is how I understand that example.
In my case I am using AOT and the tf_library macro. So I use bazel buil to call the macro and in this case I do not know how to pass the XLA_FLAGS. tf_library has an input option called flags but XLA_FLAG is not one of those. I did set the XLA_FLAG env variable, just in case, but did not work (don’t think that bazel will read linux env variables).
I am literally following this in order to the the graph compiled
In short, after preparing the frozen_graph, creating the graph.config.pbtxt and updating the BUILD with the tf_library macro info you call to:
Maybe is just that that is not the correct way to pass that option (certainly looks like that). But I do not know how pass the parameter. Do you have any idea?
Yeap I also tried that but it did not work either. I also took a look to the flags.cc file
and it did not look like that --xla_dump_to is supported. So I can see that the cpu_compiler.cc seems is contemplating that flag but then I am banging my head against the wall to provide it
Calling to tfcompile through the BUILD macro, still did not work with the llvm flag, even after following the doc from bazel that you provided, to pass the env_variables. (still quite new with Blaze to maybe its me here to blame not sure)
Anyway I followed your example calling directly tfcompile and that DID work. I can see the lovely ll files.
So thank you very much for your help and for the detail explanation on how to get the llvm dump.
Yeap, that is what I did
Also tried by exporting first the variable with the value and then just passing --action_env=XLA_FLAGS but also did not work.
Anyhow I got it working, but not using the BUILD macro but by calling directly tfcompile (as in your example)
But have you seen the experimental_get_compiler_ir method on the GenericFunction class returned by tf.function? Is there maybe a way that it could help here?
I think this is at runtime jit and not for aot, right?
If you know someone that is working on this area It could be nice to know how users could use this with bazel build and add the command in that Doc page.