(val)
| 37 | save_scalar(layer_norm.num_channels, 'n_channel', path) |
| 38 | |
| 39 | def to_tuple_tensor(val): |
| 40 | if isinstance(val, tuple): |
| 41 | # Convert tuple to Tensor |
| 42 | if len(val) == 1: |
| 43 | return Tensor([val[0], val[0]]) |
| 44 | elif len(val) == 2: |
| 45 | return Tensor([val[0], val[1]]) |
| 46 | else: |
| 47 | raise ValueError('Tuple should be of length 1 or 2 only.') |
| 48 | else: |
| 49 | # Treat as scalar and convert to Tensor |
| 50 | return Tensor([val, val]) |
| 51 | |
| 52 | def save_conv2d(conv2d, path): |
| 53 | pathlib.Path(path).mkdir(parents=True, exist_ok=True) |
no outgoing calls
no test coverage detected