swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.51k stars 10.35k forks source link

[SR-8361] GraphLowering assertion: value introduced multiple times in the same scope #50889

Closed rxwei closed 6 years ago

rxwei commented 6 years ago
Previous ID SR-8361
Radar None
Original Reporter @rxwei
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Swift for TensorFlow | |Labels | Bug | |Assignee | bgogul (JIRA) | |Priority | Medium | md5: 76806050205cea0df4636cd585273e07

duplicates:

Issue Description:

Reproducer: https://github.com/tensorflow/swift-models/tree/SR-8361

➜  Autoencoder git:(autoencoder) ✗ swift -O Autoencoder.swift
Assertion failed: ((it == valueMapping.end() || it->second < depth) && "value introduced multiple times in the same scope"), function addValueMapping, file /usr/local/src/swift-build/swift/lib/SILOptimizer/Mandatory/TFLowerGraph.cpp, line 474.
0  swift                    0x00000001130756d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000113074917 llvm::sys::RunSignalHandlers() + 39
2  swift                    0x0000000113075d52 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff62f6ef5a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000003c18 _sigtramp + 2634632408
5  libsystem_c.dylib        0x00007fff62d0c1ae abort + 127
6  libsystem_c.dylib        0x00007fff62cd41ac basename_r + 0
7  swift                    0x000000011016dfc9 (anonymous namespace)::TFGraphLowering::addValueMapping(std::__1::pair<swift::SILValue, unsigned int>, TF_Output, unsigned int) + 553
8  swift                    0x0000000110172f40 (anonymous namespace)::TFGraphLowering::visitGraphOperationInst(swift::GraphOperationInst*) + 11024
9  swift                    0x000000011016bacc (anonymous namespace)::TFGraphLowering::lowerRegion(swift::tf::SESERegionTree*) + 108
10 swift                    0x000000011017dee5 std::__1::__function::__func<(anonymous namespace)::TFGraphLowering::lowerWhileLoopRegion(swift::tf::WhileLoopSESERegion*)::$_3, std::__1::allocator<(anonymous namespace)::TFGraphLowering::lowerWhileLoopRegion(swift::tf::WhileLoopSESERegion*)::$_3>, void ()>::operator()() + 485
11 swift                    0x000000011016a292 (anonymous namespace)::TFGraphLowering::lowerToFunction(std::__1::function<void ()> const&) + 818
12 swift                    0x000000011016bee1 (anonymous namespace)::TFGraphLowering::lowerRegion(swift::tf::SESERegionTree*) + 1153
13 swift                    0x000000011016bddd (anonymous namespace)::TFGraphLowering::lowerRegion(swift::tf::SESERegionTree*) + 893
14 swift                    0x000000011016b9cd std::__1::__function::__func<lowerTFGraphOrFunction(llvm::StringRef, swift::SILFunction*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, swift::tf::GraphFunctionDeviceInfo const&, llvm::DenseMap<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> >, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> > > >&)::$_10, std::__1::allocator<lowerTFGraphOrFunction(llvm::StringRef, swift::SILFunction*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, swift::tf::GraphFunctionDeviceInfo const&, llvm::DenseMap<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> >, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> > > >&)::$_10>, void ()>::operator()() + 253
15 swift                    0x000000011016a292 (anonymous namespace)::TFGraphLowering::lowerToFunction(std::__1::function<void ()> const&) + 818
16 swift                    0x00000001101676dd lowerTFGraphOrFunction(llvm::StringRef, swift::SILFunction*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, swift::tf::GraphFunctionDeviceInfo const&, llvm::DenseMap<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> >, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> > > >&) + 1597
17 swift                    0x0000000110169e26 swift::tf::lowerTFGraph(llvm::StringRef, swift::SILFunction*, swift::tf::GraphFunctionDeviceInfo const&, llvm::DenseMap<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> >, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, std::__1::unique_ptr<swift::tf::LoweredGraphFunction, std::__1::default_delete<swift::tf::LoweredGraphFunction> > > >&) + 262
18 swift                    0x00000001101802d2 (anonymous namespace)::TFPartition::run() + 578
19 swift                    0x00000001101b7e9a swift::SILPassManager::runModulePass(unsigned int) + 346
20 swift                    0x00000001101b8827 swift::SILPassManager::execute() + 759
21 swift                    0x000000010f8eabdb swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
22 swift                    0x00000001101c0d33 swift::runSILTFPartitionPass(swift::SILModule&) + 99
23 swift                    0x000000010f77fe9e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13742
24 swift                    0x000000010f77b878 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2936
25 swift                    0x000000010f7355b8 main + 1128
26 libdyld.dylib            0x00007fff62c60015 start + 1
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-07-24-a.xctoolchain/usr/bin/swift -frontend -interpret Autoencoder.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -O -color-diagnostics -module-name Autoencoder
1.  While running pass #&#8203;0 SILModuleTransform "TFPartition".
[1]    66746 abort      swift -O Autoencoder.swift
swift-ci commented 6 years ago

Comment by Gogul Balakrishnan (JIRA)

Richard, I am not able to reproduce it on my linux box as I get the following error:

> no such module 'Foundation'

In any case, this looks related to https://bugs.swift.org/browse/SR-8298, which was fixed in PR-18173. Can you pull the latest changes and try again?

If you still get the error, can you include the SIL dump of the instruction and the basic block from where addValueMapping is invoked?

rxwei commented 6 years ago

This requires a full toolchain build, which will include `Foundation`.

I'll try a latest build.