Skip to content

map overreach? #646

@willtebbutt

Description

@willtebbutt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions