Efficient array computing is required to continue advances in fields like IoT and AI. We demonstrate a system, uarray, that does array computation generically and targets different backends. We rely on a Mathematics of Arrays, a theory of shapes and indexing, to reduce array expressions. As a result, temporary arrays and unneeded calculations are eliminated leading to minimal memory and CPU usage.
Efficient array computing is necessary to continue advances in fields like IoT and AI. In order to increase performance, hardware is becoming more specialized and heterogeneous. Therefore, it isn’t feasible for one software stack to cover the all use cases and implementations. As a result, we have seen an explosion of diverse array implementations in Python, (Pytorch, Tensorflow, CuPy, etc), each with their own silo of operations and optimizations defined. We demonstrate a system, uarray, that allows you to write array computation generically and target different backends. We rely on A Mathematics of Arrays (MoA), a theory of shapes and indexing, to reduce array expressions. By defining array operations abstractly, we can eliminate temporary arrays and unnecessary calculations, which can reduce CPU and memory usage. In this talk, we present a simple expression in NumPy that can be reduced to a more optimal form. We go through this reduction manually, by applying the rules that match. We show that the reduced form is faster theoretically and in practice. We then demonstrate how to do this reduction automatically with the uarray library and how to extend the uarray library for alternative backends and algorithms. We end with by discussing our next steps, including automatic parallelization using dimension lifting and non uniform arrays.