Skip to content

[SR-12156] Make @differentiable attribute on class methods more fine-grained #54336

@dan-zheng

Description

@dan-zheng
Previous ID SR-12156
Radar None
Original Reporter @dan-zheng
Type Sub-task
Additional Detail from JIRA
Votes 0
Component/s
Labels Sub-task
Assignee None
Priority Medium

md5: 5db9c5c7c42530ea5694370955eac541

Issue Description:

@differentiable attribute on class methods currently does two orthogonal things:

  • Requests derivative generation for the class method.

  • Adds JVP/VJP vtable entries for the class method.

There's currently no way using @differentiable to do only one of the above. There may be use cases for doing only one of the above:

  • Adding JVP/VJP vtable entries + custom derivative registration via @derivative attribute (no derivative generation).

  • Requesting derivative generation without JVP/VJP vtable entries? Maybe there's no use for this.

Supporting this may require new attribute syntax.


Note that this issue does not occur for protocol requirements, where @differentiable attribute can only mean one thing: add JVP/VJP witness table entries (and require implementations to specify same @differentiable attribute). This is because they have no function body for derivative generation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AutoDiffattributesFeature: Declaration and type attributesclassFeature → type declarations: Class declarationscompilerThe Swift compiler itselffeatureA feature request or implementationmethodsFeature → functions: methods (member functions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions