Uploaded image for project: 'Swift'
  1. Swift
  2. SR-8222

PartitionCloner::visitCondBranchInst() should be generalized to handle TensorHandle<Bool> in addition to TensorHandle<Builtin.i1>

    XMLWordPrintable

    Details

      Description

      Test case:

      public func foo() {
      let t = Tensor<Float>(1.0)
      var i = Tensor<Int32>(0)
      repeat {
      let y = t + t
      print(y)
      i += 1
      } while i != Tensor<Int32>(10)
      

      Crash stack:

      $ ../build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/bin/swiftc -frontend -emit-sil -O -Xllvm -tf-dump-intermediates -Xllvm -tf-dump-graph /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/test/TensorFlow/sends_recvs_tmp.swift >/dev/null
      swiftc: /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:2239: void (anonymous namespace)::PartitionCloner::visitCondBranchInst(swift::CondBranchInst *): Assertion `eltTy->isBuiltinIntegerType(1) && "expected Tensor<i1>"' failed.
      #0 0x0000000004bc1faf llvm::sys::PrintStackTrace(llvm::raw_ostream&) /usr/local/google/home/hongm/ssd_part/git/swift-base/llvm/lib/Support/Unix/Signals.inc:487:13
      #1 0x0000000004bc0432 llvm::sys::RunSignalHandlers() /usr/local/google/home/hongm/ssd_part/git/swift-base/llvm/lib/Support/Signals.cpp:68:18
      #2 0x0000000004bc22b2 SignalHandler(int) /usr/local/google/home/hongm/ssd_part/git/swift-base/llvm/lib/Support/Unix/Signals.inc:350:1
      #3 0x00007f7e9cc610c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
      #4 0x00007f7e88eedfcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
      #5 0x00007f7e88eef3fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
      #6 0x00007f7e88ee6e37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
      #7 0x00007f7e88ee6ee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
      #8 0x00000000012610bd (anonymous namespace)::PartitionCloner::visitCondBranchInst(swift::CondBranchInst*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:2241:17
      #9 0x0000000001254c0e swift::SILInstructionVisitor<(anonymous namespace)::PartitionCloner, void>::visit(swift::SILInstruction*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/include/swift/SIL/SILNodes.def:528:3
      #10 0x00000000012532b4 (anonymous namespace)::PartitionCloner::cloneBlock(swift::SILBasicBlock*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:3084:7
      #11 0x000000000124fe21 (anonymous namespace)::PartitionCloner::cloneFunction(llvm::ArrayRef<swift::SILValue>) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:0:5
      #12 0x000000000122ff81 (anonymous namespace)::TFFunctionPartition::partition() /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:4032:26
      #13 0x000000000122cf53 (anonymous namespace)::TFPartition::run() /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:4165:8
      #14 0x000000000109f05c swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/PassManager/PassManager.cpp:351:3
      #15 0x00000000010a0dff swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/PassManager/PassManager.cpp:434:28
      #16 0x00000000010a19c4 swift::SILPassManager::execute() /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/PassManager/PassManager.cpp:0:5
      #17 0x0000000000711c7b swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/include/swift/SILOptimizer/PassManager/PassManager.h:0:7
      #18 0x00000000010c4229 swift::runSILTFPartitionPass(swift::SILModule&) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/PassManager/Passes.cpp:142:6
      #19 0x000000000054a66f performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/FrontendTool/FrontendTool.cpp:1270:7
      #20 0x0000000000546104 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/FrontendTool/FrontendTool.cpp:980:9
      #21 0x000000000054500d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/FrontendTool/FrontendTool.cpp:1803:8
      #22 0x000000000049b684 main /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/tools/driver/driver.cpp:175:7
      #23 0x00007f7e88edb2b1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
      #24 0x0000000000493baa _start (../build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/bin/swiftc+0x493baa)
      Stack dump:
      0. Program arguments: ../build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/bin/swiftc -frontend -emit-sil -O -Xllvm -tf-dump-intermediates -Xllvm -tf-dump-graph /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/test/TensorFlow/sends_recvs_tmp.swift 
      1. While running pass #1 SILFunctionTransform "TFPartition" on SILFunction "@$S15sends_recvs_tmp3fooyyF".
      for 'foo()' at /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/test/TensorFlow/sends_recvs_tmp.swift:36:8
      Aborted 

       
      Some code changes in TFPartition.cpp from the abandoned PR https://github.com/apple/swift/pull/17821/files could be relevant. When `eltTy->isBool()` is true, we can try unwrapping the bool to get Builtin.i1, via getSingleElementDeclFieldType().

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hongm Mingsheng Hong
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: