[Misc] Replaced asserts with proper exceptions to improve UX for pooling (#44593)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -36,7 +36,11 @@ class TokenPoolerHead(nn.Module, ABC):
|
||||
pooling_metadata: PoolingMetadata,
|
||||
) -> list[TokenPoolerHeadOutputItem]:
|
||||
pooling_params = pooling_metadata.pooling_params
|
||||
assert len(pooled_data) == len(pooling_params)
|
||||
if len(pooled_data) != len(pooling_params):
|
||||
raise ValueError(
|
||||
f"pooled_data length ({len(pooled_data)}) does not match "
|
||||
f"pooling_params length ({len(pooling_params)})"
|
||||
)
|
||||
|
||||
return [self.forward_chunk(d, p) for d, p in zip(pooled_data, pooling_params)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user