comp-imaging / ProxImaL

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

Disable C-to-F casting in Halide-accelerated functions #68

Closed antonysigma closed 1 year ago

antonysigma commented 1 year ago

Assert these criteria only when implem == 'halide': For output buffers of all Prox functions, ensure they are in single-precision (float32) datatype, arranged in the Fortran-style order.

This resolves a bug: (L-)ADMM fails to converge when we explicitly define proxL1(..., implem='halide') in the problem. Previously, the Python interface Pybind11 dynamically casts the output Numpy buffers from float64 to a temporary buffer as type float32, calls Halide-accelerated pipeline, then immediately destroys the temp buffer.

Create a new test case proximal.tests.test_halide.TestHalideOps._test_algos to ensure algorithm convergence when Halide-accelerated Prox functions are specified in the problem.


Similarly, ensure all input buffers are in single-precision datatype in Fortran-style order.

Rationale: Halide-acceleration of the Prox functions are only justified when we can avoid the explicit memory copy and type casting. Otherwise, the Halide implementation can run slower than the native Numpy/Numexpr implementation.

Related to #67 .

SteveDiamond commented 1 year ago

@antonysigma I sent you an invite to have more permissions for this repo.

antonysigma commented 1 year ago

@antonysigma I sent you an invite to have more permissions for this repo.

@SteveDiamond Thank you for inviting me as the contributing member. Shall I self approve pull requests?

Also, am I supposed to add my name to the MIT license to strengthen the legal protection?

SteveDiamond commented 1 year ago

You can self-approve pull requests.