debug.py 711 B

123456789101112131415161718192021
  1. import torch._C._lazy
  2. def render_ir_graph(tensors):
  3. """Return a text dump of the LTC IR graph in dot format for the tensors.
  4. The text can be processed by tools like dot to be rendered in pdf,png etc."""
  5. return torch._C._lazy._get_tensors_dot(tensors)
  6. def dump_ir(tensors, ir_format):
  7. """Return a dump of the tensors in the specified format.
  8. Valid format are
  9. - text: for LTC IR
  10. - backend: for the activate backend IR
  11. """
  12. if ir_format == "text":
  13. return torch._C._lazy._get_tensors_text(tensors)
  14. elif ir_format == "backend":
  15. return torch._C._lazy._get_tensors_backend(tensors)
  16. else:
  17. raise RuntimeError(f"Unrecognized IR format: {ir_format}")