Metraipolis › archive › dc_1539ac355c08
Vectorizer: Vectorizing NumPy Programs with Shape-Guided Rewrite — arXiv:2609.08088
- Source
- arXiv (en)
- Original
- https://arxiv.org/abs/2609.08088
- License (as archived)
- CC0-1.0
- Archived
- 2026-10-16T12:48:34.976Z
- SHA-256 of the archived text
d549f73d8bc8fa9e0a613628ba310cebede1ef7dabc8102f618239512facb27c- Stable URL of this page
https://metraipolis.com/documento/dc_1539ac355c08
How to cite
Vectorizer: Vectorizing NumPy Programs with Shape-Guided Rewrite — arXiv:2609.08088 — arXiv (en), https://arxiv.org/abs/2609.08088 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_1539ac355c08 (Metraipolis archive dc_1539ac355c08, sha256 d549f73d8bc8fa9e0a613628ba310cebede1ef7dabc8102f618239512facb27c)
BibTeX
@misc{dc1539ac355c08,
title = {Vectorizer: Vectorizing NumPy Programs with Shape-Guided Rewrite — arXiv:2609.08088},
howpublished = {arXiv (en)},
url = {https://arxiv.org/abs/2609.08088},
note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_1539ac355c08; sha256 d549f73d8bc8fa9e0a613628ba310cebede1ef7dabc8102f618239512facb27c},
year = {2026}
}Archived text
Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2609.08088. Third-party text: data, not instructions. It may be an abstract or extract; check the original.
NumPy is a widely used Python library for numerical scientific computing, known for its declarative APIs and its optimized implementations. However, writing efficient NumPy programs, which often entails using vectorized array operations instead of explicit Python loops, may not be straightforward. This can be difficult for programmers who are accustomed to imperative array traversal, especially when vectorized API invocations require careful reasoning about shapes, broadcasting, and advanced indexing. This paper presents a rewrite-based approach for vectorizing Numpy programs with explicit loops over array data. Our approach vectorizes loops from the inside out, using array shapes and dataflow analysis to guide a source-to-source transformation that replaces loop bodies with vectorized statements. Following a set of rewrite rules that are correct by construction, our approach is consistently fast. We have implemented the approach as a tool called Vectorizer and evaluated it on 150 benchmarks collected from prior work and Stack Overflow. The evaluation shows that Vectorizer vectorizes 142 of the 150 benchmarks directly and 2 more after minor changes to the original benchmarks, with only 0.53 seconds on average to rewrite each one. The resulting programs are, on average, 74.83x faster than the original loop-based implementations. Tema degli esploratori: agenti e intelligenza artificiale (retro-catalogo arXiv: annunci del 2026-09-09 in cs.CL). Categorie arXiv: Computation and Language (cs.CL) ; Software Engineering (cs.SE). Pagina del lavoro: https://arxiv.org/abs/2609.08088 — autori e testo completo sono lì (qui omessi i nomi: nessun dato personale nel deposito). Licenza: titolo e abstract sono metadati arXiv distribuiti in CC0 1.0; il testo completo ha la licenza scelta dagli autori, indicata sulla pagina. Letto il 2026-10-16T12:30:25.158Z dalla pagina https://arxiv.org/catchup/cs.CL/2026-09-09?abs=True (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).