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-9683] [AD] Copy generic signature in primal synthesis #52125

Closed
dan-zheng opened this issue Jan 17, 2019 · 0 comments
Closed

[SR-9683] [AD] Copy generic signature in primal synthesis #52125

dan-zheng opened this issue Jan 17, 2019 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-9683
Radar None
Original Reporter @dan-zheng
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Swift for TensorFlow
Labels Bug
Assignee @dan-zheng
Priority Medium

md5: 26b01a0a332a46f64ec4b49463b83f5b

Issue Description:

When function to differentiate doesn't specify adjoint/vjp, primal synthesis occurs.
If function is in a generic context, SIL verification fails because primal isn't synthesized with a generic signature.

import TensorFlow
extension Tensor where Scalar : FloatingPoint & Differentiable {
  @differentiable(wrt: (self))
  func hello() -> Tensor {
    return self
  }
}
SIL verification failed: generic function definition must have a generic environment: !FTy->isPolymorphic()
In function:
// AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__primal_src_0_wrt_0
sil hidden @AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__primal_src_0_wrt_0 : $@convention(method) <τ_0_0 where τ_0_0 : Differentiable, τ_0_0 : FloatingPoint, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>) -> (@owned AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__Type__src_0_wrt_0, @owned Tensor<τ_0_0>) {
// %0                                             // users: %4, %2, %1
bb0(%0 : $Tensor<Scalar>):
  debug_value %0 : $Tensor<Scalar>, let, name "self", argno 1 // id: %1
  retain_value %0 : $Tensor<Scalar>               // id: %2
  %3 = struct $AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__Type__src_0_wrt_0 () // user: %4
  %4 = tuple (%3 : $AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__Type__src_0_wrt_0, %0 : $Tensor<Scalar>) // user: %5
  return %4 : $(AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__Type__src_0_wrt_0, Tensor<Scalar>) // id: %5
} // end sil function 'AD__$s10TensorFlow0A0V8generic2s14DifferentiableRzSFRzrlE5helloACyxGyF__primal_src_0_wrt_0'

We should synthesize generic signature for primal identical to that of the original function.

@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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow
Projects
None yet
Development

No branches or pull requests

1 participant