[4/N] Initialize MM components in context managers (M-P) (#32663)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -71,8 +71,6 @@ def _require_is_multimodal(is_multimodal: Tensor | None) -> Tensor:
|
||||
|
||||
|
||||
class LMMissingLayer(nn.Module):
|
||||
packed_modules_mapping: dict[str, list[str]] = {}
|
||||
|
||||
def make_empty_intermediate_tensors(self, *args, **kwargs):
|
||||
raise RuntimeError("This module should not be called in MM encoder-only mode")
|
||||
|
||||
@@ -81,8 +79,6 @@ class LMMissingLayer(nn.Module):
|
||||
|
||||
|
||||
class TowerMissingLayer(nn.Module):
|
||||
packed_modules_mapping: dict[str, list[str]] = {}
|
||||
|
||||
def __init__(self, modalities: set[str] | str) -> None:
|
||||
if isinstance(modalities, str):
|
||||
modalities = {modalities}
|
||||
@@ -92,7 +88,10 @@ class TowerMissingLayer(nn.Module):
|
||||
self.modalities = modalities
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
raise RuntimeError(f"The following modalities are disabled: {self.modalities}")
|
||||
raise RuntimeError(
|
||||
f"This module should not be called when the following "
|
||||
f"modalities are disabled: {self.modalities}"
|
||||
)
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
||||
Reference in New Issue
Block a user