Skip to content

[SR-12154] Fix vtable entry type mismatch verification error for @differentiable(wrt: self) #53490

@dan-zheng

Description

@dan-zheng
Previous ID SR-12154
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: 66daea3fab4a15a8539d2d766d092b41

is blocked by:

  • TF-625 [AD] Change differentials/pullbacks to be maximally indirect

Issue Description:

Reproducer:

class Super : Differentiable {
  var base: Float = 0
  // Dummy to make `Super.AllDifferentiableVariables` be nontrivial.
  // var _nontrivial: [Float] = []

  @differentiable(wrt: self)
  func f() -> Float {
    return 1
  }
}

class Sub : Super {
  @differentiable(wrt: self)
  override func f() -> Float {
    return 1
  }
}
SIL verification failed: vtable entry for #Super.f!1.jvp.1.S must be ABI-compatible
  ABI incompatible return values
  @convention(method) (@guaranteed Super) -> (Float, @owned @callee_guaranteed (@guaranteed Super.AllDifferentiableVariables) -> Float)
  @convention(method) (@guaranteed Sub) -> (Float, @owned @callee_guaranteed (Super.AllDifferentiableVariables) -> Float)

This error occurs because class Super is non-trivial but struct Super.AllDifferentiableVariables is trivial.
Should be fixed by TF-625 by making differentials/pullbacks maximally indirect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AutoDiffattributesFeature: Declaration and type attributesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions