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

[llvm] Add support for accessing ProGraML as JSON. #332

Merged
merged 1 commit into from
Jul 26, 2021

Conversation

ChrisCummins
Copy link
Contributor

This adds a new ProgramlJson observation space that bypasses the
networkx graph construction and instead returns the raw node link data
for ProGraML graphs:

>>> import compiler_gym
>>> env = compiler_gym.make("llvm-v0")
>>> env.reset()
>>> env.observation.ProgramlJson()
...
{'block': 60,
 'features': {'full_text': ['store i32 %182, i32* %17, align 4, !tbaa !4']},
 'function': 13,
 'id': 995,
 'text': 'store',
 'type': 0},
{'block': 60,
 'features': {'full_text': ['i32 %182']},
 'function': 13,
 'id': 996,
 'text': 'i32',
 'type': 1},
{'block': 60,
 'features': {'full_text': ['i32* %17']},
 'function': 13,
 'id': 997,
 'text': 'i32*',
 'type': 1},
{'block': 60,
 'features': {'full_text': ['br label %183']},
 'function': 13,
 'id': 998,
 'text': 'br',
 'type': 0},
{'block': 61,
 'features': {'full_text': ['%184 = load i8*, i8** %9, align 8, !tbaa !0']},
 'function': 13,
 'id': 999,
 'text': 'load',
 'type': 0},
...]}

This adds a new ProgramlJson observation space that bypasses the
networkx graph construction and instead returns the raw node link data
for ProGraML graphs:

    >>> import compiler_gym
    >>> env = compiler_gym.make("llvm-v0")
    >>> env.reset()
    >>> env.observation.ProgramlJson()
    ...
    {'block': 60,
     'features': {'full_text': ['store i32 %182, i32* %17, align 4, !tbaa !4']},
     'function': 13,
     'id': 995,
     'text': 'store',
     'type': 0},
    {'block': 60,
     'features': {'full_text': ['i32 %182']},
     'function': 13,
     'id': 996,
     'text': 'i32',
     'type': 1},
    {'block': 60,
     'features': {'full_text': ['i32* %17']},
     'function': 13,
     'id': 997,
     'text': 'i32*',
     'type': 1},
    {'block': 60,
     'features': {'full_text': ['br label %183']},
     'function': 13,
     'id': 998,
     'text': 'br',
     'type': 0},
    {'block': 61,
     'features': {'full_text': ['%184 = load i8*, i8** %9, align 8, !tbaa !0']},
     'function': 13,
     'id': 999,
     'text': 'load',
     'type': 0},
    ...]}
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 20, 2021
Copy link
Contributor

@bcui19 bcui19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bcui19 bcui19 merged commit 19047db into facebookresearch:development Jul 26, 2021
@ChrisCummins ChrisCummins deleted the programl-dgl branch July 26, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants