Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -157,8 +157,7 @@ def _is_layer_none_or_staged(layer: nn.Module) -> bool:
|
||||
|
||||
|
||||
class PixtralImagePixelInputs(TensorSchema):
|
||||
"""
|
||||
Dimensions:
|
||||
"""Dimensions:
|
||||
- bn: Batch size * number of images
|
||||
- c: Number of channels (3)
|
||||
- h: Height of each image
|
||||
@@ -688,8 +687,7 @@ class VisionEncoderArgs:
|
||||
|
||||
|
||||
def _reshape_for_broadcast(freqs_cis: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
|
||||
"""
|
||||
freqs_cis: complex - (seq_len, head_dim / 2)
|
||||
"""freqs_cis: complex - (seq_len, head_dim / 2)
|
||||
x: complex - (bsz, seq_len, head_dim / 2)
|
||||
"""
|
||||
ndim = x.ndim
|
||||
@@ -708,9 +706,8 @@ def precompute_freqs_cis_2d(
|
||||
width: int,
|
||||
theta: float,
|
||||
) -> torch.Tensor:
|
||||
"""
|
||||
freqs_cis: 2D complex tensor of shape (height, width, dim // 2)
|
||||
to be indexed by (height, width) position tuples
|
||||
"""freqs_cis: 2D complex tensor of shape (height, width, dim // 2)
|
||||
to be indexed by (height, width) position tuples
|
||||
"""
|
||||
# (dim / 2) frequency bases
|
||||
freqs = 1.0 / (theta ** (torch.arange(0, dim, 2).float() / dim))
|
||||
@@ -1018,13 +1015,14 @@ class VisionTransformer(nn.Module):
|
||||
self,
|
||||
images: list[torch.Tensor],
|
||||
) -> torch.Tensor:
|
||||
"""
|
||||
Args:
|
||||
"""Args:
|
||||
images: list of N_img images of variable sizes,
|
||||
each of shape (C, H, W)
|
||||
|
||||
Returns:
|
||||
image_features: tensor of token features for
|
||||
all tokens of all images of shape (N_toks, D)
|
||||
|
||||
"""
|
||||
# pass images through initial convolution independently
|
||||
patch_embeds_list = [
|
||||
@@ -1082,9 +1080,7 @@ class VisionLanguageAdapter(nn.Module):
|
||||
|
||||
|
||||
class PatchMerger(nn.Module):
|
||||
"""
|
||||
Learned merging of spatial_merge_size ** 2 patches
|
||||
"""
|
||||
"""Learned merging of spatial_merge_size ** 2 patches."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -1124,8 +1120,7 @@ class PatchMerger(nn.Module):
|
||||
x: torch.Tensor,
|
||||
image_sizes: list[tuple[int, int]],
|
||||
) -> torch.Tensor:
|
||||
"""
|
||||
Args:
|
||||
"""Args:
|
||||
x: (N, D) where N is flattened and concatenated patch tokens
|
||||
for all images
|
||||
image_sizes: list of tuple of (height, width) in tokens for
|
||||
@@ -1134,8 +1129,8 @@ class PatchMerger(nn.Module):
|
||||
image_features: reorders patch tokens so each grid of
|
||||
(spatial_merge_size, spatial_merge_size) is contiguous.
|
||||
now (N / spatial_merge_size ** 2, D * spatial_merge_size ** 2)
|
||||
"""
|
||||
|
||||
"""
|
||||
sub_grids = get_sub_grids(
|
||||
x=x, image_sizes=image_sizes, spatial_merge_size=self.spatial_merge_size
|
||||
) # list of [d x sub_grid_size x sub_grid_size x n_patches]
|
||||
@@ -1509,8 +1504,7 @@ class PixtralHFVisionModel(nn.Module):
|
||||
select_layers: list[int] | None = None,
|
||||
feature_select_strategy: VisionFeatureSelectStrategy | None = None,
|
||||
) -> tuple[torch.Tensor, ...]:
|
||||
"""
|
||||
Args:
|
||||
"""Args:
|
||||
pixel_values: Each image to be processed will be a separate tensor
|
||||
in pixel_values. This means it will be a list of tensors
|
||||
because multiple requests batched can have multiple images,
|
||||
@@ -1522,6 +1516,7 @@ class PixtralHFVisionModel(nn.Module):
|
||||
Returns:
|
||||
image_features: tensor of token features for
|
||||
all tokens of all images of shape (N_toks, D)
|
||||
|
||||
"""
|
||||
# pass images through initial convolution independently
|
||||
patch_embeds_list = [
|
||||
|
||||
Reference in New Issue
Block a user