Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sam2/csrc/connected_components.cu
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ __global__ void final_counting(

std::vector<torch::Tensor> get_connected_componnets(
const torch::Tensor& inputs) {

AT_ASSERTM(inputs.is_cuda(), "inputs must be a CUDA tensor");
AT_ASSERTM(inputs.ndimension() == 4, "inputs must be [N, 1, H, W] shape");
AT_ASSERTM(
Expand Down Expand Up @@ -240,7 +241,8 @@ std::vector<torch::Tensor> get_connected_componnets(
dim3 grid_count =
dim3((W + BLOCK_COLS) / BLOCK_COLS, (H + BLOCK_ROWS) / BLOCK_ROWS);
dim3 block_count = dim3(BLOCK_COLS, BLOCK_ROWS);
cudaStream_t stream = at::cuda::getCurrentCUDAStream();
auto device_idx = inputs.device().index();
cudaStream_t stream = at::cuda::getCurrentCUDAStream(device_idx);

for (int n = 0; n < N; n++) {
uint32_t offset = n * H * W;
Expand Down