Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

Map isn't differentiable but compiler diagnosis is gone  #554

Description

@porterchild

I though Dan had talked about .map becoming differentiable recently in an open design meeting, but there is still an issue as of the 9/16 Xcode snapshot. The compiler lets this through, but it produces an incorrect derivative:

func mappy(a: [Double]) -> Double{
    let twice = a.map{$0 * 2}                   //compiles, but resulting gradient is incorrect (empty list)
//    let twice = a.differentiableMap{$0 * 2}   //works, gradient is [2.0, 2.0, 2.0]
    
    return twice.differentiableReduce(0, +)
}

print(valueWithGradient(at: [1,2,3], in: mappy))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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