Name | numba-rvsdg JSON |
Version |
0.0.5
JSON |
| download |
home_page | |
Summary | Numba Compatible RVSDG utilities |
upload_time | 2023-08-15 08:35:31 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.11 |
license | BSD-2-Clause |
keywords |
numba
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# numba-rvsdg
Numba compatible RVSDG (Regionalized Value State Dependence Graph) utilities.
## about
This repository contains Numba compatible utilities for working with RVSDGs
(Regionalized Value State Dependency Graphs). RVSDGs are a type of
Intermediary Representation (IR) suitable for regularizing Python bytecode
within Numba.
The code in this repository is an implementation of the CFG restructuring
algorithms in Bahmann 2015, specifically those from section 4.1 and 4.2: namely
"loop restructuring" and "branch restructuring". These are interesting for
Numba because they serve to clearly identify regions within the Python
bytecode.
## dependencies
* Python 3.11
* graphviz
* pyyaml
You can create a conda env using the following:
```
conda env create -n numba-rvsdg python=3.11 python-graphviz
conda activate numba-rvsdg
pip install pyyaml
```
At the time of writing `pyyaml` was not available for Python 3.11 via
`defaults` so it had to be installed with `pip`.
## overview
The following files are included in this repository:
```
numba_rvsdg
├── __init__.py
├── core
│ ├── datastructures
│ │ ├── basic_block.py # BasicBlock implementation
│ │ ├── scfg.py # SCFG implementation, maps names to blocks
│ │ ├── byte_flow.py # ByteFlow implementation, SCFG + bytecode
│ │ ├── flow_info.py # Converts program to ByteFlow
│ ├── transformations.py # Algorithms
│ └── utils.py # Miscellaneous utilities
├── networkx_vendored
│ └── scc.py # Strongly Connected Componets (loop detection)
├── rendering
│ └── rendering.py # Graphivz based rendering of SCFGs
├── tests
│ ├── simulator.py # Simulator utility for running SCFGs
│ ├── test_byteflow.py # Testung ByteFlow and others
│ ├── test_fig3.py # Testing fig. 3 from Bahman2015
│ ├── test_fig4.py # Testing fig. 4 from Bahman2015
│ ├── test_simulate.py # Simulator based testing
│ └── test_transforms.py # Testing graph transformations
└── utils
```
## example
The following will process the given example function and display the four
different stages. "initial" is the unprocessed bytecode as produced by
cpython. "closed" is simply the closed variant of the initial CFG. "loop
restructuring" is the loop-restructured version and "branch-restructured" is
the final form which includes closing, loop-restructuring and
branch-restructuring.
```python
# Example: for loop with branch and early exit
from numba_rvsdg.rendering.rendering import render_func
def foo(n):
c = 0
for i in range(n):
c += 1
if i == 100:
break
return c
render_func(foo)
```
![initial](docs/images/initial.png "initial")
![closed](docs/images/closed.png "closed")
![loop-restructured](docs/images/loop_restructured.png "loop-restructured")
![branch-restructured](docs/images/branch_restructured.png "branch-restructured")
## references
* `Reismann2020` -- https://arxiv.org/pdf/1912.05036.pdf -- Describes the concept of RVSDGs
* `Bahmann2015` -- https://dl.acm.org/doi/pdf/10.1145/2693261 -- Describes the transformation
algorithms implemented
## license
Copyright (c) 2022, Anaconda, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Raw data
{
"_id": null,
"home_page": "",
"name": "numba-rvsdg",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "numba",
"author": "",
"author_email": "Numba Developers <none@none.none>",
"download_url": "https://files.pythonhosted.org/packages/10/04/f29ee7653c6926791ec32179bbc8342597a1a4921ce6892073c97bd8c906/numba_rvsdg-0.0.5.tar.gz",
"platform": null,
"description": "# numba-rvsdg\n\nNumba compatible RVSDG (Regionalized Value State Dependence Graph) utilities.\n\n## about\n\nThis repository contains Numba compatible utilities for working with RVSDGs\n(Regionalized Value State Dependency Graphs). RVSDGs are a type of\nIntermediary Representation (IR) suitable for regularizing Python bytecode\nwithin Numba.\n\nThe code in this repository is an implementation of the CFG restructuring\nalgorithms in Bahmann 2015, specifically those from section 4.1 and 4.2: namely\n\"loop restructuring\" and \"branch restructuring\". These are interesting for\nNumba because they serve to clearly identify regions within the Python\nbytecode.\n\n## dependencies\n\n* Python 3.11\n* graphviz\n* pyyaml\n\nYou can create a conda env using the following:\n\n```\nconda env create -n numba-rvsdg python=3.11 python-graphviz\nconda activate numba-rvsdg\npip install pyyaml\n```\n\nAt the time of writing `pyyaml` was not available for Python 3.11 via\n`defaults` so it had to be installed with `pip`.\n\n## overview\n\nThe following files are included in this repository:\n\n```\nnumba_rvsdg\n\u251c\u2500\u2500 __init__.py\n\u251c\u2500\u2500 core\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 datastructures\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 basic_block.py # BasicBlock implementation\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 scfg.py # SCFG implementation, maps names to blocks\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 byte_flow.py # ByteFlow implementation, SCFG + bytecode\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 flow_info.py # Converts program to ByteFlow\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 transformations.py # Algorithms\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 utils.py # Miscellaneous utilities\n\u251c\u2500\u2500 networkx_vendored\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 scc.py # Strongly Connected Componets (loop detection)\n\u251c\u2500\u2500 rendering\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 rendering.py # Graphivz based rendering of SCFGs\n\u251c\u2500\u2500 tests\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 simulator.py # Simulator utility for running SCFGs\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test_byteflow.py # Testung ByteFlow and others\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test_fig3.py # Testing fig. 3 from Bahman2015\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test_fig4.py # Testing fig. 4 from Bahman2015\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test_simulate.py # Simulator based testing\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test_transforms.py # Testing graph transformations\n\u2514\u2500\u2500 utils\n```\n\n## example\n\nThe following will process the given example function and display the four\ndifferent stages. \"initial\" is the unprocessed bytecode as produced by\ncpython. \"closed\" is simply the closed variant of the initial CFG. \"loop\nrestructuring\" is the loop-restructured version and \"branch-restructured\" is\nthe final form which includes closing, loop-restructuring and\nbranch-restructuring.\n\n\n```python\n# Example: for loop with branch and early exit\n\nfrom numba_rvsdg.rendering.rendering import render_func\n\ndef foo(n):\n c = 0\n for i in range(n):\n c += 1\n if i == 100:\n break\n return c\n\nrender_func(foo)\n\n```\n\n![initial](docs/images/initial.png \"initial\")\n![closed](docs/images/closed.png \"closed\")\n![loop-restructured](docs/images/loop_restructured.png \"loop-restructured\")\n![branch-restructured](docs/images/branch_restructured.png \"branch-restructured\")\n\n## references\n\n* `Reismann2020` -- https://arxiv.org/pdf/1912.05036.pdf -- Describes the concept of RVSDGs\n* `Bahmann2015` -- https://dl.acm.org/doi/pdf/10.1145/2693261 -- Describes the transformation\n algorithms implemented\n\n## license\n\nCopyright (c) 2022, Anaconda, Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\nRedistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n",
"bugtrack_url": null,
"license": "BSD-2-Clause",
"summary": "Numba Compatible RVSDG utilities",
"version": "0.0.5",
"project_urls": null,
"split_keywords": [
"numba"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e2dcbfb3d7219698953454965f5dad0fa35e9264fe6df3f01af24a3d7bf95a31",
"md5": "ce2c36988a5742e89441d62cd9df960a",
"sha256": "62359a2a275bad4daff50a05eaaa4c3341cfe81fe4c997e56e8c6d61d9b49a5b"
},
"downloads": -1,
"filename": "numba_rvsdg-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ce2c36988a5742e89441d62cd9df960a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 43879,
"upload_time": "2023-08-15T08:35:29",
"upload_time_iso_8601": "2023-08-15T08:35:29.143581Z",
"url": "https://files.pythonhosted.org/packages/e2/dc/bfb3d7219698953454965f5dad0fa35e9264fe6df3f01af24a3d7bf95a31/numba_rvsdg-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1004f29ee7653c6926791ec32179bbc8342597a1a4921ce6892073c97bd8c906",
"md5": "31f7b5a200c08820bc4d017929a7e448",
"sha256": "49f01cb55319802b523e0b7fbb0eb071fda86718bedea034b6cd1a9b308e1cb7"
},
"downloads": -1,
"filename": "numba_rvsdg-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "31f7b5a200c08820bc4d017929a7e448",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 37751,
"upload_time": "2023-08-15T08:35:31",
"upload_time_iso_8601": "2023-08-15T08:35:31.185523Z",
"url": "https://files.pythonhosted.org/packages/10/04/f29ee7653c6926791ec32179bbc8342597a1a4921ce6892073c97bd8c906/numba_rvsdg-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-15 08:35:31",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "numba-rvsdg"
}