Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Improve TensorFlow runtime errors #904

@ematejska

Description

@ematejska

Imported from JIRA https://bugs.swift.org/browse/TF-458

Type: Sub-task Priority: Minor
Reporter: Dan Zheng Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

TensorFlow runtime errors don't have meaning source location info.

Reproducers:

import TensorFlow
let x = Tensor<Float>(ones: [2, 3])
_ = matmul(x, x)
// Fatal error: Matrix size-incompatible: In[0]: [2,3], In[1]: [2,3]: file /usr/local/src/swift-build/swift/stdlib/public/TensorFlow/CompilerRuntime.swift, line 2108
// [1]    65743 illegal hardware instruction  ./tf-458
import TensorFlow
let x = Tensor(1)
_ = Raw.print(x, data: [x], message: "Hello!")
// Fatal error: NodeDef missing attr 'U' from Op<name=Print; signature=input:T, data: -> output:T; attr=T:type; attr=U:list(type),min=0; attr=message:string,default=""; attr=first_n:int,default=-1; attr=summarize:int,default=3; is_stateful=true>; NodeDef: {{node Print}}: file /usr/local/src/swift-build/swift/stdlib/public/TensorFlow/CompilerRuntime.swift, line 2108
[1]    65900 illegal hardware instruction  ./tf-458-2

When interpreting with swift (instead of compilation using swiftc), stack dumps are long:

Fatal error: Matrix size-incompatible: In[0]: [2,3], In[1]: [2,3]: file /usr/local/src/swift-build/swift/stdlib/public/TensorFlow/CompilerRuntime.swift, line 2108
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.3-a.xctoolchain/usr/bin/swift -frontend -interpret tf-458.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name main
0  swift                    0x000000010d94b025 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010d94a2c5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010d94b612 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff590fef5a _sigtramp + 26
4  libsystem_platform.dylib 0x00007f8faca470f6 _sigtramp + 1402241462
5  libswiftCore.dylib       0x0000000114c47849 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 25
6  libswiftTensorFlow.dylib 0x00000001151e0fed $s10TensorFlow24internalConsistencyCheck__4file4lineySb_SSs12StaticStringVSutF + 429
7  libswiftTensorFlow.dylib 0x00000001151deb92 $s10TensorFlow7checkOk_4file4lineys13OpaquePointerVSg_s12StaticStringVSutF + 482
8  libswiftTensorFlow.dylib 0x000000011520bf81 $s10TensorFlow11_TFCCheckOkyys13OpaquePointerVF + 81
9  libswiftTensorFlow.dylib 0x000000011520bf29 _swift_tfc_CheckOk + 9
10 libswiftTensorFlow.dylib 0x0000000115222cfd $s10TensorFlow3RawO6matMul__10transposeA0F1BAA0A0VyxGAI_AIS2btSjRzAA0aB6ScalarRzlFZ + 525
11 libswiftTensorFlow.dylib 0x000000011521db68 $s10TensorFlow6matmulyAA0A0VyxGAE_AEtSjRzAA0aB6ScalarRzlF + 72
12 libswiftTensorFlow.dylib 0x00000001156760a3 $s10TensorFlow6matmulyAA0A0VyxGAE_AEtSjRzAA0aB6ScalarRzlF + 4556163
13 swift                    0x000000010a3e6ff8 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 456
14 swift                    0x000000010a3ea941 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 1313
15 swift                    0x0000000109caa2e1 swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 3537
16 swift                    0x0000000109c84251 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13041
17 swift                    0x0000000109c7fef8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3016
18 swift                    0x0000000109c31c22 main + 690
19 libdyld.dylib            0x00007fff58df0015 start + 1
20 libdyld.dylib            0x000000000000000a start + 2803957750
[1]    66008 illegal hardware instruction  swift tf-458.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions