comp-imaging / ProxImaL

A domain-specific language for image optimization.
MIT License
112 stars 29 forks source link

Code generation with ProxImaL #65

Closed antonysigma closed 1 year ago

antonysigma commented 1 year ago

Refactor proximal.algorithm.linearized_admm from Python to Halide language. The C++17 template function LinearizedADMM::iterate() describes the pipeline representing one iteration of the L-ADMM algorithm. Similarly, LinearizedADMM::computeConvergence() for computing primal and dual residuals.

It is expected that the end-users modify the file proximal/halide/src/user-problem/problem-config.h containing the problem input and output data size. Also, implement the following pipelines:

in the file problem-definition.h . A Jinja2/Python template is provided at proximal/templates to facilitate the code generation in ProxImaL (code gen feature not yet implemented).

The Halide cross-compilation performs symbolic simplification to substitute all intermediate functions (e.g. K, omega_fns, psi_fns) into the ADMM algorithm: image and parallelize/vectorize intermedate stages where it makes sense.

The performance boost compared to existing ProxImaL varies upon the problem families; highest performance boost can be obtained if all absorbed proximal parameters (e.g. alpha, beta, omega, etc), as well as the CopyNode in K: image are completely eliminated by Halide.

Note: perhaps someone should write a research article about it.

Resolves https://github.com/comp-imaging/ProxImaL/issues/57

jrk commented 1 year ago

@antonysigma This is awesome! At the start of the project we aspired to one day get to end-to-end codegen, but never did, so this is really cool to see.

antonysigma commented 1 year ago

Thanks @jrk and @SteveDiamond for the complement. I applaud your effort to open source Halide and Proximal in pursuit of reproducible research.

The industry needs pioneers of 4th/5th generation language to solve complex problems. Without tools like these, ISP engineers and researcher out there are still stuck in polishing Matlab and LabVIEW in house.

Although this PR is a halfway solution to the end-to-end codegen, I believe by contributing back, someone else can eventually finish it.