Skip to content

Commit 03793e7

Browse files
committed
Minor fixes
1 parent e370bc4 commit 03793e7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

k2/csrc/intersect_dense_pruned.cu

+10
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,17 @@ OnlineDenseIntersecter::OnlineDenseIntersecter(FsaVec &a_fsas,
15921592
}
15931593

15941594
OnlineDenseIntersecter::~OnlineDenseIntersecter(){
1595+
// WARNING(Wei Kang): Python garbage collector runs in a separate thread,
1596+
// so we have to reset its default device. Otherwise, it will throw later
1597+
// if the main thread is using a different device.
1598+
// Actually, it is the `CheckEmpty` function invoked in Hash's destructor
1599+
// would throw, but I think it is properly to put the DeviceGuard here, as the
1600+
// hanging occurs when destructing this object.
1601+
// Note: The hanging only occurs on the versions built with debug mode, as the
1602+
// release mode won't invoked `CheckEmpty` when destructing Hash objects.
1603+
#ifndef NDEBUG
15951604
DeviceGuard guard(c_);
1605+
#endif
15961606
delete impl_;
15971607
}
15981608

0 commit comments

Comments
 (0)