[Model] Explicit default_pooling_type interface (#23736)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2025-08-27 13:24:09 +00:00
committed by GitHub
parent 704432af3c
commit 5eeef1b908
11 changed files with 51 additions and 33 deletions
+1 -18
View File
@@ -3,7 +3,7 @@
from collections.abc import Iterable, Mapping, MutableSequence
from typing import (TYPE_CHECKING, ClassVar, Literal, Optional, Protocol,
TypeVar, Union, overload, runtime_checkable)
Union, overload, runtime_checkable)
import numpy as np
import torch
@@ -641,23 +641,6 @@ def supports_cross_encoding(
return is_pooling_model(model) and _supports_cross_encoding(model)
_T = TypeVar("_T", bound=type[torch.nn.Module])
def default_pooling_type(pooling_type: str):
"""Set default_pooling_type decorator. """
def func(model: _T) -> _T:
model.default_pooling_type = pooling_type # type: ignore
return model
return func
def get_default_pooling_type(model: Union[type[object], object]) -> str:
return getattr(model, "default_pooling_type", "LAST")
class SupportsQuant:
"""The interface required for all models that support quantization."""