NDFA
A hierarchic code encoder that encodes statements locally, then passes information between them globally.
Language · 797 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Language
- Parameters
- 25M
- Operations
- 797
- Framework
- PyTorch
- Recurrent
- Yes
- Published
- 2022, MSc thesis, Technion - Israel Institute of Technology
- Authors
- Elad Nachmias
- Source
- GitHub: eladn/NDFA
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m18650
- Graph hash
- 4647e95e086e41e2b433dde54c9326f14d766a4fabd651b513f864d464107bde
- Skeleton hash
- 7942c5cdc9fdf776e98006a6042f70c258a203fde51eb70c3f15896519648252
- Architecture hash
- 2239a64a8628e4716811b730439036637e7107803e62b24db596d76f133e56b6
- Diagram SHA-256
- b69a9b782060c45bd5893c959fed33b1c9928d4897e69e070f839375c1817f8e
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
NDFA (Neural Data-Flow Analysis) is a set of neural models for source code, and its principal one is the Hierarchic model, built for tasks where information has to propagate through a program the way data flow does. The thesis behind it addresses one such task: predicting which variables to log at a given logging insertion point in a program.
The procedure's code is broken at the statement level into a two-level structure. A micro operator first produces a local encoding for each individual statement. A macro operator then passes contextual information globally between statements, through relationships such as control flow. The local encodings are then mixed with the globally aware ones, and the micro operator is applied once more. A decoder of two LSTM layers, with attention over the encoder output vectors, produces the output symbols.
The thesis models semantic relations as paths in the procedure's control-flow graph (CFG) and syntactic relations as paths in the abstract syntax tree (AST). A second idea, a graph encoding framework called expand-collapse, extends the paths-based encoder by letting information flow across paths. The experiments use three datasets of code snippets written in Java. The author reports that the model is more effective than the other representations compared, by up to 10% in accuracy.
Key idea. The thesis built a hierarchic code encoder that splits a procedure into local and global levels, and an expand-collapse framework that lets information flow across paths.
- ndfa
- neural data-flow analysis
- hierarchic code encoder
- hierarchical code representations
- logvar
- logging variable prediction
- source code representation
- control-flow graph paths
- ast paths
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@article{ndfa2022,
title = {Hierarchical Code Representations},
author = {Elad Nachmias},
year = {2022},
journal = {MSc thesis, Technion - Israel Institute of Technology}
}