swift-apis icon indicating copy to clipboard operation
swift-apis copied to clipboard

Runtime TensorFlow errors do not point back to the originating source

Open ematejska opened this issue 5 years ago • 0 comments

Imported from JIRA https://bugs.swift.org/si/jira.issueviews:issue-html/TF-225

Type: Bug Priority: Major
Reporter: Brennan Saeta Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

In the following code:

import TensorFlow

struct Model: Layer {
  var w = Tensor<Float>(randomNormal: [6, 6], mean: 1, stddev: 1)
  var b = Tensor<Float>(zeros: [10])

  @differentiable(wrt: (self, input))
  func applied(to input: Tensor<Float>) -> Tensor<Float> {
    return matmul(input, w) + b + b.transposed()
  }
}

let m = Model()
m.applied(to: Tensor<Float>(zeros: [3]))

we get the following error:

Fatal error: In[0] is not a matrix. Instead it has shape [3]: file /swift-base/swift/stdlib/public/TensorFlow/CompilerRuntime.swift, line 2044
Current stack trace:
0    libswiftCore.so                    0x00007fb027392e30 _swift_stdlib_reportFatalErrorInFile + 115
1    libswiftCore.so                    0x00007fb0272db49c <unavailable> + 2999452
2    libswiftCore.so                    0x00007fb0272db58e <unavailable> + 2999694
3    libswiftCore.so                    0x00007fb027123272 <unavailable> + 1196658
4    libswiftCore.so                    0x00007fb0272a5792 <unavailable> + 2779026
5    libswiftCore.so                    0x00007fb0271226b9 <unavailable> + 1193657
6    libswiftTensorFlow.so              0x00007fb0247e0f12 <unavailable> + 405266
7    libswiftTensorFlow.so              0x00007fb0247df670 checkOk(_:file:line:) + 491
8    libswiftTensorFlow.so              0x00007fb0248001a0 _TFCCheckOk(_:) + 81
9    libswiftTensorFlow.so              0x00007fb024800190 _swift_tfc_CheckOk + 9
Current stack trace:
	frame #8: 0x00007fb01b48543f $__lldb_expr656`specialized Model.applied(input=<unavailable>) at <Cell 33>:7
	frame #10: 0x00007fb01b4889e6 $__lldb_expr668`main at <Cell 34>:2:3

The error should point back to the actual operation that failed (matmul) and the symbolic name of the problematic input variable (input).

ematejska avatar Apr 28 '20 16:04 ematejska