Skip to content

Commit 8b14573

Browse files
committed
prevent crash when trying to fill an empty tensor
1 parent b718b9a commit 8b14573

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/kernels/fill.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ __global__ void fill_kernel(floatX* dst, floatX value, std::size_t count) {
1717

1818
template<typename floatX>
1919
void fill_imp(floatX* dst, floatX value, std::size_t count, cudaStream_t stream) {
20+
if (count == 0) return;
21+
if (dst == nullptr) throw std::invalid_argument("dst is nullptr");
2022
fill_kernel<<<div_ceil(count, static_cast<std::size_t>(256)), 256, 0, stream>>> (dst, value, count);
2123
CUDA_CHECK(cudaGetLastError());
2224
}

0 commit comments

Comments
 (0)