-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistent valuation @ shared 'Acc'
when trying to lift non-Acc
function to Acc
#489
Comments
As far as I can see (but it's late, I'll check again tomorrow) this behaviour can't be supported by Accelerate. You can 'compose' Acc programs using |
@dpvanbalen I don't see a good way to separate objective functions from optimizers in this situation. Different optimizers call objective functions in different ways, and some may call an objective function multiple times or an indeterminate number of times. Maybe I don't understand something about Accelerate, but couldn't a function like |
It sounds like your |
@tmcdonell That looks close to what I'm looking for. My liftAcc :: (Arrays as, Arrays bs) => (as -> bs) -> Acc as -> Acc bs Unlike |
The fallback choice allows you to chain multiple implementations, presumably ending with one written in pure accelerate (or, error). I don't think we can really entirely remove the dependency on the particular backend, however, because e.g. a GPU needs to copy the results back to the host, but the CPU does not. |
@tmcdonell It sounds like you could implement P.S. One of my motivations for wanting a function like |
Description
I am working on a machine learning/mathematical optimization library with
accelerate
for array computation. An optimization algorithm typically takes an objective function, likeA.Acc (A.Vector Bool) -> A.Acc (A.Scalar b)
, as an argument. Not all objective functions can be described in terms ofAcc
, so it is important that a user can "lift" a non-Acc
function toAcc
, likeA.use . f . A.run
.To ensure
accelerate
is capable of this, I put together a trivial lifted objective function:However, when I tried to run an optimizer on this, I got an error:
If you replace
liftedSumBools
withthere is no error.
Steps to reproduce
Run this program: https://gist.github.com/JustinLovinger/49b81dc83284732c05e4b657670b57c0.
Expected behaviour
Program runs without error.
Your environment
Additional context
While trying to create a minimal reproduction, I ran into a different error,
derivative-free-comparison: Cyclic definition of a value of type 'Acc' (sa = 26)
:This program doesn't give an error if you replace
liftedSumBools
withor
aiterate 2 (step liftedSumBools)
withstep liftedSumBools $ step liftedSumBools
.The text was updated successfully, but these errors were encountered: