Skip to main content

ProGraML: Program Graphs for Machine Learning

PyPI version PyPi Downloads License

An expressive, language-independent representation of programs.

Check the website for more information.

Introduction

ProGraML is a representation for programs as input to a machine learning model. The key features are:

  1. Simple: Everything is available through a pip install, no compilation required. Supports several programming languages (C, C++, LLVM-IR, XLA) and several graph formats (NetworkX, DGL, Graphviz, JSON) out of the box.

  2. Expressive: Captures every control, data, and call relation across entire programs. The representation is independent of the source language. Features and labels can be added at any granularity to support whole-program, per-instruction, or per-relation reasoning tasks.

  3. Fast: The core graph construction is implemented in C++ with a low overhead interface to Python. Every API method supports simple and efficient parallelization through an executor parameter.

To get stuck in and play around with our graph representation, visit:

Or if papers are more your ☕, have a read of ours:

Supported Programming Languages

The following programming languages and compiler IRs are supported out-of-the-box:

Language API Calls Supported Versions
C programl.from_cpp(), programl.from_clang() Up to ISO C 2017
C++ programl.from_cpp(), programl.from_clang() Up to ISO C++ 2020 DIS
LLVM-IR programl.from_llvm_ir() 3.8.0, 6.0.0, 10.0.0
XLA programl.from_xla_hlo_proto() 2.0.0

Is your favorite language not supported here? Submit a feature request!

Getting Started

Install the latest release of the Python package using:

pip install -U programl

The API is very simple, comprising graph creation ops, graph transform ops, and graph serialization ops. Here is a quick demo of each:

>>> import programl as pg

# Construct a program graph from C++:
>>> G = pg.from_cpp("""
... #include <iostream>
...
... int main(int argc, char** argv) {
...   std::cout << "Hello, world!" << std::endl;
...   return 0;
... }
... """)

# A program graph is a protocol buffer:
>>> type(G).__name__
'ProgramGraph'

# Convert the graph to NetworkX:
>>> pg.to_networkx(G)
<networkx.classes.multidigraph.MultiDiGraph at 0x7fbcf40a2fa0>

# Save the graph for later:
>>> pg.save_graphs('file.data', [G])

For further details check out the API reference.

Contributing

Patches, bug reports, feature requests are welcome! Please use the issue tracker to file a bug report or question. If you would like to help out with the code, please read this document.

Citation

If you use ProGraML in any of your work, please cite this paper:

@inproceedings{cummins2021a,
  title={{ProGraML: A Graph-based Program Representation for Data Flow Analysis and Compiler Optimizations}},
  author={Cummins, Chris and Fisches, Zacharias and Ben-Nun, Tal and Hoefler, Torsten and O'Boyle, Michael and Leather, Hugh},
  booktitle = {Thirty-eighth International Conference on Machine Learning (ICML)},
  year={2021}
}

Metadata

Release files for programl 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for programl 0.3.2
File Interpreter ABI Platform
programl-0.3.2-py3-none-manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
programl-0.3.2-py3-none-macosx_10_15_x86_64.whl Python 3 none macOS 10.15+ x86-64 Details

Total release size: 91.3 MB

Release files / programl-0.3.2-py3-none-manylinux2014_x86_64.whl

Download URL programl-0.3.2-py3-none-manylinux2014_x86_64.whl
Size 43.8 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
79e88a4d87adb98bc6f860c6284910db3f962212e75493ba3768003c66ecb9a6
BLAKE2b-256 checksum
How to use checksums
442d9537ac3526bc51fcf82a580c1f1c936bc1fc3bba00062468bc8efc98d474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / programl-0.3.2-py3-none-macosx_10_15_x86_64.whl

Download URL programl-0.3.2-py3-none-macosx_10_15_x86_64.whl
Size 47.5 MB
Tags Python 3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
5479b1f592ceb4a8bfe9b6c75d4f12e89652ed00c198b2281159e134cfbffb5a
BLAKE2b-256 checksum
How to use checksums
e33792350c0811e146234b94f93de065e903238f6db80b614f00b0dc4503f890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page