feat: added cleaved_layers property
Browse files- modeling_bert.py +9 -0
modeling_bert.py
CHANGED
@@ -177,6 +177,15 @@ class BertEncoder(nn.Module):
|
|
177 |
assert 0 <= idx < len(self.layers)
|
178 |
self._last_layer_idx = idx
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
@property
|
181 |
def gradient_checkpointing(self):
|
182 |
return self._grad_checkpointing
|
|
|
177 |
assert 0 <= idx < len(self.layers)
|
178 |
self._last_layer_idx = idx
|
179 |
|
180 |
+
@property
|
181 |
+
def cleaved_layers(self):
|
182 |
+
return len(self.layers) - self.last_layer_idx - 1
|
183 |
+
|
184 |
+
@cleaved_layers.setter
|
185 |
+
def cleaved_layers(self, n: int):
|
186 |
+
assert 0 <= n < len(self.layers)
|
187 |
+
self.last_layer_idx = len(self.layers) - n - 1
|
188 |
+
|
189 |
@property
|
190 |
def gradient_checkpointing(self):
|
191 |
return self._grad_checkpointing
|