(module, op_name)
| 157 | return {name: m for name, m in module.named_modules() if isinstance(m, nn.Linear)} |
| 158 | |
| 159 | def get_op_by_name(module, op_name): |
| 160 | # get the op by its name relative to the module |
| 161 | for name, m in module.named_modules(): |
| 162 | if name == op_name: |
| 163 | return m |
| 164 | raise ValueError(f"Cannot find op {op_name} in module {module}") |
| 165 | |
| 166 | def get_op_name(module, op): |
| 167 | # get the name of the op relative to the module |