Reshaped views might alias

One possible workaround is to replace broadcast expressions with map!, which doesn’t check for aliasing. Schematically, replace

y .= f.(x)

with

map!(f, y, x)

This is less flexible in that it doesn’t expand singleton dimensions like broadcasting does, but if it fits your use case it can help you save on the explicit loops.

3 Likes