This repository was archived by the owner on Jul 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
Error message for non-scalar Tensor case. #278
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When taking the gradient of a function, the function must return a scalar. Because Tensors do not encode their shape or rank, this is checked dynamically at runtime. Previously, we did not provide an error message, resulting in the following error messages: Precondition failed: file /swift-base/tensorflow-swift-apis/Sources/TensorFlow/Core/DifferentialOperators.swift, line 68 Current stack trace: 0 libswiftCore.so 0x00007f1629f45830 swift_reportError + 50 1 libswiftCore.so 0x00007f1629fb45d0 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007f1629edca7e <unavailable> + 3734142 3 libswiftCore.so 0x00007f1629edcbf7 <unavailable> + 3734519 4 libswiftCore.so 0x00007f1629cab10d <unavailable> + 1433869 5 libswiftCore.so 0x00007f1629eb1a88 <unavailable> + 3558024 6 libswiftCore.so 0x00007f1629caa569 <unavailable> + 1430889 9 repl_swift 0x0000000000400490 <unavailable> + 1168 11 libswiftCore.so 0x00007f1629caa569 <unavailable> + 1430889 14 repl_swift 0x0000000000400490 <unavailable> + 1168 16 libswiftCore.so 0x00007f1629caa569 <unavailable> + 1430889 17 libswiftTensorFlow.so 0x00007f16272250b0 <unavailable> + 2543792 18 libswiftTensorFlow.so 0x00007f1627098280 checkOk(_:file:line:) + 467 19 libswiftTensorFlow.so 0x00007f162709f480 TFE_Op.evaluateUnsafe() + 506 20 libswiftTensorFlow.so 0x00007f162709fcf0 TFE_Op.execute<A>(_:) + 132 21 libswiftTensorFlow.so 0x00007f16270a8984 <unavailable> + 985476 22 libswiftTensorFlow.so 0x00007f162713dc20 static Raw.matMul<A>(_:_:transposeA:transposeB:) + 1221 23 libswiftTensorFlow.so 0x00007f1627293c00 matmul<A>(_:transposed:_:transposed:) + 1427 24 libswiftTensorFlow.so 0x00007f16272f6210 _vjpMatmul<A>(_:transposed:_:transposed:) + 201 25 libswiftTensorFlow.so 0x00007f16273564b4 <unavailable> + 3794100 26 libswiftTensorFlow.so 0x00007f162731f960 AD__$s10TensorFlow5DenseV14callAsFunctionyAA0A0VyxGAGF__vjp_src_0_wrt_0_1 + 680 31 repl_swift 0x0000000000400490 <unavailable> + 1168 Current stack trace: frame #4: 0x00007f162b926120 $__lldb_expr57`main at <Cell 8>:1 This change provides the user with a bit more context and prints out the shape their computation produced to help them debug what might have gone wrong.
Note: I'm open to suggestions for what to call the "forward pass", if you have thoughts. |
eaplatanios
reviewed
Jun 22, 2019
I know it's too much, but could we suggest or point to an example by which the person could debug his code? |
eaplatanios
reviewed
Jun 22, 2019
rxwei
reviewed
Jun 22, 2019
rxwei
approved these changes
Jun 22, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
eaplatanios
approved these changes
Jun 22, 2019
Thanks Brennan! |
Thank you @eaplatanios and @rxwei for speedy reviews! :-) |
Note, looks like this is TF-320 (https://bugs.swift.org/browse/TF-320) Marking as fixed. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When taking the gradient of a function, the function must return a scalar.
Because Tensors do not encode their shape or rank, this is checked dynamically
at runtime. Previously, we did not provide an error message, resulting in the
following error messages:
This change provides the user with a bit more context and prints out the shape
their computation produced to help them debug what might have gone wrong.