apply Black 25.11.0 style in fbcode/deeplearning/projects (21/92)
Summary: Formats the covered files with pyfmt. paintitblack Reviewed By: itamaro Differential Revision: D90476315 fbshipit-source-id: ee94c471788b8e7d067813d8b3e0311214d17f3f
This commit is contained in:
committed by
meta-codesync[bot]
parent
7b89b8fc3f
commit
11dec2936d
@@ -36,9 +36,9 @@ def connected_components_cpu(input_tensor: torch.Tensor):
|
||||
if input_tensor.dim() == 4 and input_tensor.shape[1] == 1:
|
||||
input_tensor = input_tensor.squeeze(1)
|
||||
else:
|
||||
assert (
|
||||
input_tensor.dim() == 3
|
||||
), "Input tensor must be (B, H, W) or (B, 1, H, W)."
|
||||
assert input_tensor.dim() == 3, (
|
||||
"Input tensor must be (B, H, W) or (B, 1, H, W)."
|
||||
)
|
||||
|
||||
batch_size = input_tensor.shape[0]
|
||||
labels_list = []
|
||||
@@ -67,9 +67,9 @@ def connected_components(input_tensor: torch.Tensor):
|
||||
if input_tensor.dim() == 3:
|
||||
input_tensor = input_tensor.unsqueeze(1)
|
||||
|
||||
assert (
|
||||
input_tensor.dim() == 4 and input_tensor.shape[1] == 1
|
||||
), "Input tensor must be (B, H, W) or (B, 1, H, W)."
|
||||
assert input_tensor.dim() == 4 and input_tensor.shape[1] == 1, (
|
||||
"Input tensor must be (B, H, W) or (B, 1, H, W)."
|
||||
)
|
||||
|
||||
if input_tensor.is_cuda:
|
||||
if HAS_CC_TORCH:
|
||||
|
||||
@@ -6,7 +6,6 @@ import logging
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
from sam3.perflib.masks_ops import mask_iou
|
||||
|
||||
|
||||
|
||||
@@ -407,16 +407,16 @@ def connected_components_triton(input_tensor: torch.Tensor):
|
||||
- A BxHxW output tensor with dense labels. Background is 0.
|
||||
- A BxHxW tensor with the size of the connected component for each pixel.
|
||||
"""
|
||||
assert (
|
||||
input_tensor.is_cuda and input_tensor.is_contiguous()
|
||||
), "Input tensor must be a contiguous CUDA tensor."
|
||||
assert input_tensor.is_cuda and input_tensor.is_contiguous(), (
|
||||
"Input tensor must be a contiguous CUDA tensor."
|
||||
)
|
||||
out_shape = input_tensor.shape
|
||||
if input_tensor.dim() == 4 and input_tensor.shape[1] == 1:
|
||||
input_tensor = input_tensor.squeeze(1)
|
||||
else:
|
||||
assert (
|
||||
input_tensor.dim() == 3
|
||||
), "Input tensor must be (B, H, W) or (B, 1, H, W)."
|
||||
assert input_tensor.dim() == 3, (
|
||||
"Input tensor must be (B, H, W) or (B, 1, H, W)."
|
||||
)
|
||||
|
||||
B, H, W = input_tensor.shape
|
||||
numel = B * H * W
|
||||
|
||||
Reference in New Issue
Block a user