(module: nn.Module, requires_grad: Optional[bool] = None)
| 46 | |
| 47 | |
| 48 | def num_parameters(module: nn.Module, requires_grad: Optional[bool] = None) -> int: |
| 49 | total = 0 |
| 50 | for p in module.parameters(): |
| 51 | if requires_grad is None or p.requires_grad == requires_grad: |
| 52 | if hasattr(p, 'quant_state'): |
| 53 | # bitsandbytes 4bit layer support |
| 54 | total += math.prod(p.quant_state.shape) |
| 55 | else: |
| 56 | total += p.numel() |
| 57 | return total |
| 58 | |
| 59 | |
| 60 | def reset_parameters(module: nn.Module) -> None: |
no outgoing calls
no test coverage detected