mlsanityData to 7 Oct 2026

Vectorizer: Vectorizing NumPy Programs with Shape-Guided Rewrite

arXiv 2609.08088 ↗First posted 8 Sep 2026cs.CL cs.SEcited by 0

Not on the map. Why?

Abstract (arXiv)

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.

Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 7 of its 51 references that are in the map. First posted on arXiv 8 Sep 2026.

Builds on

7 of 51 references.

References · 7

  1. 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,160
  2. 2015MXNet: A Flexible and Efficient Machine Learning Library for Heterogeneous Distributed Systemscited by 195
  3. 2020TF-Coder: Program Synthesis for Tensor Manipulationscited by 27
  4. 2022Predictive Synthesis of API-Centric Codecited by 3
  5. 2024Tenspiler: A Verified Lifting-Based Compiler for Tensor Operations (Extended Version)cited by 2
  6. 2018Stepping Stones to Inductive Synthesis of Low-Level Looping Programscited by 1
  7. 2025Guided Tensor Liftingcited by 1

Built on by

Not cited yet.