Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13682] incorrect (?) "function not differentiable" error #54382

Closed
marcrasi mannequin opened this issue Dec 17, 2019 · 1 comment
Closed

[SR-13682] incorrect (?) "function not differentiable" error #54382

marcrasi mannequin opened this issue Dec 17, 2019 · 1 comment

Comments

@marcrasi
Copy link
Mannequin

marcrasi mannequin commented Dec 17, 2019

Previous ID SR-13682
Radar None
Original Reporter @marcrasi
Type Sub-task
Status Closed
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s
Labels Sub-task
Assignee None
Priority Medium

md5: ade1d1d5746c480bf642439650ccd571

Parent-Task:

  • SR-13659 Retroactive derivative registration

Issue Description:

After #28790 is merged,

public enum FunctionInModule1_InternalDerivatives {
  public static func f(_ x: Float) -> Float { x }

  @derivative(of: f)
  static func df(_ x: Float) -> (value: Float, pullback: (Float) -> Float) {
    (x, { $0 })
  }
  public static func gradFFromModule1(_ x: Float) -> Float { gradient(at: x, in: f) }
}

gives:

workspace/ufa.swift:8:82: error: function is not differentiable
  public static func gradFFromModule1(_ x: Float) -> Float { gradient(at: x, in: f) }
                                                                                 ^
workspace/ufa.swift:2:22: note: differentiated functions in '@inlinable' functions must be marked '@differentiable' or have a public '@derivative'
  public static func f(_ x: Float) -> Float { x }
                     ^

If you add `@usableFromInline` to `df`, the error goes away. If you write the same thing as top-level functions, the error goes away.

@marcrasi
Copy link
Mannequin Author

marcrasi mannequin commented Jan 8, 2020

Obsolete because I'm closing the PR that causes this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants