The result contains the program before and after optimization.
Enabling HLO dumping
Dumping is driven by the XLA compiler's own dump mechanism, enabled through
the XLA_FLAGS environment variable. Two flags are required:
--xla_dump_hlo_as_text– dump the HLO in text form.--xla_dump_to=<dir>– write the dump into<dir>.inspect_hlo()reads the HLO back from the files XLA writes here.
XLA reads XLA_FLAGS once, before the first compilation in an R process,
so both flags must be set at the very start of a fresh session, before any
pjrt_compile() or pjrt_execute() call:
Sys.setenv(XLA_FLAGS = "--xla_dump_to=/tmp/hlo --xla_dump_hlo_as_text")
library(pjrt)
# ... build a program ...
inspect_hlo(prog)