Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Outputting pre-IRGen code #3230

Closed
ghost opened this issue Jul 12, 2019 · 2 comments
Closed

Question: Outputting pre-IRGen code #3230

ghost opened this issue Jul 12, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 12, 2019

As I understand (partly from the white paper, and partly from reading the Glow source code), the IRGen stage is optional. For the sake of concreteness, let's focus on the CPU backend. After lowering has been performed, many of the operations are replaced with BLAS, which are currently implemented in the CPU backend libjit. After this, the optional IRGen is performed that compiles the high level IR to the low level IR.

My question is whether it is possible to output, in whatever format, the state of high level IR prior to IRGen? Ideally, is it possible to output it as C source code?

I do not see this in the current code base, but I wonder whether this is planned, or how difficult it may be to do.

@jfix71
Copy link
Contributor

jfix71 commented Jul 12, 2019

You're correct that IRGen is optional. For example our Habana backend skips low-level IR; Glow high-level Nodes are translated into Habana-specific IR and passed to the Habana stack.

We do not have functionality to output any level of the graph as C source code. Something like this was asked in #2585, you can see @nadavrot's suggestion there. You could iterate over either level of IR and do so. We do not have any plans for this currently.

We do have the ability to print out a dot file with a DAG of the high-level graph. This can be done via -dump-graph-DAG="file.dot". We also have a PR in progress to export a Glow high-level graph via ONNX in #3167. Otherwise we have some options for backends that use the low level IR, such as -dump-ir. And then there's also LLVM-specific options like -dump-llvm-ir and -dump-llvm-asm, which must be used with an LLVM-based backend like the CPU backend.

And just to make sure it's clear:

After lowering has been performed, many of the operations are replaced with BLAS, which are currently implemented in the CPU backend libjit.

libjit includes implementations for Instructions (our low-level IR), not for Nodes (high-level IR). There is often a 1-to-1 mapping from Nodes to Instructions during IRGen, but not always.

@ghost
Copy link
Author

ghost commented Jul 12, 2019

Excellent, thanks @jfix71 !

@ghost ghost closed this as completed Jul 12, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant