We gratefully acknowledge support from
the Simons Foundation and member institutions.
Full-text links:

Download:

Current browse context:

cs.LG

Change to browse by:

References & Citations

DBLP - CS Bibliography

Bookmark

(what is this?)
CiteULike logo BibSonomy logo Mendeley logo del.icio.us logo Digg logo Reddit logo

Computer Science > Machine Learning

Title: Neural Code Comprehension: A Learnable Representation of Code Semantics

Abstract: With the recent success of embeddings in natural language processing, research has been conducted into applying similar methods to code analysis. Most works attempt to process the code directly or use a syntactic tree representation, treating it like sentences written in a natural language. However, none of the existing methods are sufficient to comprehend program semantics robustly, due to structural features such as function calls, branching, and interchangeable order of statements. In this paper, we propose a novel processing technique to learn code semantics, and apply it to a variety of program analysis tasks. In particular, we stipulate that a robust distributional hypothesis of code applies to both human- and machine-generated programs. Following this hypothesis, we define an embedding space, inst2vec, based on an Intermediate Representation (IR) of the code that is independent of the source programming language. We provide a novel definition of contextual flow for this IR, leveraging both the underlying data- and control-flow of the program. We then analyze the embeddings qualitatively using analogies and clustering, and evaluate the learned representation on three different high-level tasks. We show that even without fine-tuning, a single RNN architecture and fixed inst2vec embeddings outperform specialized approaches for performance prediction (compute device mapping, optimal thread coarsening); and algorithm classification from raw code (104 classes), where we set a new state-of-the-art.
Comments: Published at NeurIPS 2018
Subjects: Machine Learning (cs.LG); Neural and Evolutionary Computing (cs.NE); Programming Languages (cs.PL); Machine Learning (stat.ML)
Cite as: arXiv:1806.07336 [cs.LG]
  (or arXiv:1806.07336v3 [cs.LG] for this version)

Submission history

From: Tal Ben-Nun [view email]
[v1] Tue, 19 Jun 2018 16:43:44 GMT (1511kb,D)
[v2] Tue, 31 Jul 2018 16:10:52 GMT (1513kb,D)
[v3] Thu, 29 Nov 2018 08:15:00 GMT (1957kb,D)

Link back to: arXiv, form interface, contact.