-
-
Notifications
You must be signed in to change notification settings - Fork 216
Description
Zygote's current map implementation is arguably a bit optimistic about the types of things that it's able to handle.
For example, this issue in KernelFunctions.jl cropped up because we define a custom AbstractVector type that wraps a Matrix, and lets it masquerade as a vector-of-vectors.
Under the hood, this type makes sure to implement various operations efficiently on the wrapped matrix. It would be reasonable to assume that Zygote would be able to exploit these efficient implementations (because composition), but instead it hits the map adjoint and literally treats the object as a vector-of-vectors, which is bad for performance.
I would propose to impose further type constraints on the implementation of map, perhaps to StridedArray or DenseArray, whichever is deemed a better target. @MikeInnes @dhairyagandhi96 any thoughts?