Skip to content
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

LazyExpressions and broadcasting #70

Open
schmrlng opened this issue Aug 8, 2018 · 2 comments
Open

LazyExpressions and broadcasting #70

schmrlng opened this issue Aug 8, 2018 · 2 comments

Comments

@schmrlng
Copy link
Contributor

schmrlng commented Aug 8, 2018

When defining constraints like @constraint(m, v >= 0) for Vector-valued v on Julia 0.7 we get this deprecation warning

┌ Warning: `a::AbstractArray - b::Number` is deprecated, use `a .- b` instead.
│   caller = optimize_toplevel at lazyexpression.jl:59 [inlined]
└ @ Core ~/.julia/packages/SimpleQP/pHx4o/src/lazyexpression.jl:59

This comes from the minus expressions here but naively replacing those with broadcasted equivalents interferes with the current LazyExpression optimizations. I feel like the answer is to either integrate base broadcasting into LazyExpressions (a potentially daunting task) or to make a localized fix (e.g., maybe turn just this line into a broadcasted equivalent?); what do you think?

@tkoolen
Copy link
Owner

tkoolen commented Aug 8, 2018

I've been using @constraint(m, v >= zeros(n)) everywhere so I hadn't run into this yet. That will always remain a valid way to do this, so it's certainly an option for if you want to get rid of the depwarns on 0.7 right now.

Transforming . syntax into broadcast calls in @expression will be annoying, but is doable. I'm hoping that Julia will provide a function for this kind of 'normalization' of the AST (it used to just be expand), but its 0.7-equivalent, lower, unfortunately returns something entirely different.

After that's done, we'd need to add optimize methods for broadcast calls. Unfortunately, it's not as simply as turning broadcast into broadcast!, because if v is a Vector{<:AffineFunction}, then scalar subtraction also allocates.

So it's certainly not impossible, but it's quite a task to get this right.

@tkoolen
Copy link
Owner

tkoolen commented Aug 9, 2018

This probably also becomes easier if we switch to a Cassette-based implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants