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-9623] [AD] Compiler crashes for nested layers. #52069

Closed
swift-ci opened this issue Jan 8, 2019 · 1 comment
Closed

[SR-9623] [AD] Compiler crashes for nested layers. #52069

swift-ci opened this issue Jan 8, 2019 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 8, 2019

Previous ID SR-9623
Radar None
Original Reporter xiejw (JIRA User)
Type Bug
Status Resolved
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Swift for TensorFlow
Labels Bug
Assignee @rxwei
Priority Medium

md5: 224c7327241f2dc228b561adea0fd0ed

Issue Description:

The following code snippet triggers

struct Dense:  Differentiable {
  var w: Float

  var b: Float

  func forward(_ x: Float) -> Float {
    return w * x + b
  }
}


print("Now gradient for one layer.")
let layer = Dense(w: 1.0, b: 2.0)
let grad = gradient(at: layer) { model in
  model.forward(2.0)
}

print("grad: \(grad)")

struct Model: Differentiable {

  var layer_1 = Dense(w: 1.0, b: 2.0)
  var layer_2 = Dense(w: 3.0, b: 5.0)

  func forward(_ x: Float) -> Float {
    return layer_2.forward(layer_1.forward(x))
  }
}

print("Now gradient for model (nested layers).")
let model = Model()
let gradForModel = gradient(at: model) { model in
  model.forward(2.0)
}

print("grad: \(gradForModel)")
@rxwei
Copy link
Member

rxwei commented Jan 9, 2019

Actually this does not crash at the head of tensorflow branch.

Now gradient for one layer.
grad: CotangentVector(w: 2.0, b: 1.0)
Now gradient for model (nested layers).
grad: CotangentVector(layer_1: test.Dense.CotangentVector(w: 6.0, b: 3.0), layer_2: test.Dense.CotangentVector(w: 4.0, b: 1.0))

@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

2 participants