Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8222] PartitionCloner::visitCondBranchInst() should be generalized to handle TensorHandle<Bool> in addition to TensorHandle<Builtin.i1> #50754

Closed
swift-ci opened this issue Jul 10, 2018 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers swift for tensorflow

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8222
Radar None
Original Reporter hongm (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Swift for TensorFlow
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: 2743ead28421c5ee11dc3426da08ac60

Issue 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.
#&#8203;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
#&#8203;1 0x0000000004bc0432 llvm::sys::RunSignalHandlers() /usr/local/google/home/hongm/ssd_part/git/swift-base/llvm/lib/Support/Signals.cpp:68:18
#&#8203;2 0x0000000004bc22b2 SignalHandler(int) /usr/local/google/home/hongm/ssd_part/git/swift-base/llvm/lib/Support/Unix/Signals.inc:350:1
#&#8203;3 0x00007f7e9cc610c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#&#8203;4 0x00007f7e88eedfcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
#&#8203;5 0x00007f7e88eef3fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
#&#8203;6 0x00007f7e88ee6e37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
#&#8203;7 0x00007f7e88ee6ee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
#&#8203;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
#&#8203;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
#&#8203;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
#&#8203;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
#&#8203;12 0x000000000122ff81 (anonymous namespace)::TFFunctionPartition::partition() /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:4032:26
#&#8203;13 0x000000000122cf53 (anonymous namespace)::TFPartition::run() /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/Mandatory/TFPartition.cpp:4165:8
#&#8203;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
#&#8203;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
#&#8203;16 0x00000000010a19c4 swift::SILPassManager::execute() /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/PassManager/PassManager.cpp:0:5
#&#8203;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
#&#8203;18 0x00000000010c4229 swift::runSILTFPartitionPass(swift::SILModule&) /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/lib/SILOptimizer/PassManager/Passes.cpp:142:6
#&#8203;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
#&#8203;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
#&#8203;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
#&#8203;22 0x000000000049b684 main /usr/local/google/home/hongm/ssd_part/git/swift-base/swift/tools/driver/driver.cpp:175:7
#&#8203;23 0x00007f7e88edb2b1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
#&#8203;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 #&#8203;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().

@swift-ci
Copy link
Collaborator Author

Comment by Mingsheng Hong (JIRA)

I'm trying to remove code for handling UncheckedRefCast, and in that process it seems we'll need to fix this bug, so I can look into this.

@swift-ci
Copy link
Collaborator Author

Comment by Ding Ye (JIRA)

Hi Mingsheng, just noticed you intend to have this one resolved in order to make another progress. If you have not started yet, please take a look at 18074. Otherwise, please feel free to close that PR, since there isn't much code modified.

@swift-ci
Copy link
Collaborator Author

Comment by Mingsheng Hong (JIRA)

Thank you Ding. Let's try and get your PR in. 🙂

@swift-ci
Copy link
Collaborator Author

Comment by Ding Ye (JIRA)

#18074

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers swift for tensorflow
Projects
None yet
Development

No branches or pull requests

1 participant