| 6 | |
| 7 | |
| 8 | class MultiBlock(nn.Module): |
| 9 | def __init__(self, *args, **kwargs) -> None: |
| 10 | super().__init__(*args, **kwargs) |
| 11 | self.block_list = nn.ModuleList([]) |
| 12 | |
| 13 | def add_block(self, block): |
| 14 | self.block_list.append(block) |
| 15 | |
| 16 | def forward(self, |
| 17 | hidden_states: torch.Tensor, |
| 18 | attention_mask: Optional[torch.Tensor] = None, |
| 19 | position_ids: Optional[torch.LongTensor] = None): |
| 20 | for block in self.block_list: |
| 21 | hidden_states = block(hidden_states, attention_mask=attention_mask,position_ids=position_ids)[0] |
| 22 | return (hidden_states, ) |
| 23 | |
| 24 | |
| 25 | def set_weight_parameters(model, requires_grad): |
nothing calls this directly
no outgoing calls
no test coverage detected