Uploaded image for project: ' Swift for TensorFlow'
  1. Swift for TensorFlow
  2. TF-93

Deabstraction should properly diagnose recursion

    XMLWordPrintable

    Details

      Description

      We do not support partitioning recursive functions, and it is okay. However, it should not crash. Need proper diagnostics before doing inlining.

      import TensorFlow
      
      public indirect enum T {
        case leaf(Tensor<Float>)
        case node(T, Tensor<Float>, T)
      }
      
      public func reduce(_ tree: T) -> Tensor<Float> {
        switch tree {
        case .leaf(let v):
          return v
        case .node(let x, let v, let y):
          return reduce(x) + v + reduce(y)
        }
      }
      
      test.swift:13:12: error: inlining 'transparent' functions forms circular loop
          return reduce(x) + v + reduce(y)
                 ^
      Assertion failed: (callee != &fn && "inlining self into self??"), function inlineCalls, file /usr/local/src/swift-build/swift/lib/SILOptimizer/Mandatory/TFDeabstraction.cpp, line 291.
      0  swift                    0x000000010f17da48 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
      1  swift                    0x000000010f17cc87 llvm::sys::RunSignalHandlers() + 39
      2  swift                    0x000000010f17e0c2 SignalHandler(int) + 258
      3  libsystem_platform.dylib 0x00007fff75e6ff5a _sigtramp + 26
      4  libdyld.dylib            0x00007fff75b61149 dyldGlobalLockRelease() + 0
      5  libsystem_c.dylib        0x00007fff75c0d1ae abort + 127
      6  libsystem_c.dylib        0x00007fff75bd51ac basename_r + 0
      7  swift                    0x000000010c24e8a7 (anonymous namespace)::TFDeabstraction::doIt() + 13223
      8  swift                    0x000000010c24b343 (anonymous namespace)::TFDeabstractionPass::run() + 563
      9  swift                    0x000000010c2b77ba swift::SILPassManager::runModulePass(unsigned int) + 346
      10 swift                    0x000000010c2b8147 swift::SILPassManager::execute() + 759
      11 swift                    0x000000010b9cc90b swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
      12 swift                    0x000000010c2c0234 swift::runSILDiagnosticPasses(swift::SILModule&) + 132
      13 swift                    0x000000010b864bfa performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13130
      14 swift                    0x000000010b86083f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2943
      15 swift                    0x000000010b814a38 main + 1128
      16 libdyld.dylib            0x00007fff75b61015 start + 1
      Stack dump:
      0.	Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-08-31-a.xctoolchain/usr/bin/swift -frontend -emit-sil -primary-file test.swift -target x86_64-apple-darwin17.7.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name test -o -
      1.	While running pass #36 SILModuleTransform "TFDeabstraction".
      2.	TFDeabstraction on function $S4test6reducey10TensorFlow0C0VySfGAA1TOF
      3.	TFDeabstraction::inlineCalls
      [1]    20383 abort      swiftc test.swift -emit-sil
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                xinranmsn Richard Wei
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: