Skip to content

Commit

Permalink
Correctly build models and import call_context for older TF versions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocketknight1 authored and sgugger committed Jun 9, 2023
1 parent fe861e5 commit 50ed793
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/modeling_tf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
from keras.engine.keras_tensor import KerasTensor
else:
from tensorflow.python.keras import backend as K
from tensorflow.python.keras.engine import call_context
from tensorflow.python.keras.engine.base_layer_utils import call_context
from tensorflow.python.keras.engine.keras_tensor import KerasTensor


Expand Down Expand Up @@ -1156,8 +1156,8 @@ def build(self, input_shape=None):
if self.built or call_context().in_call:
self.built = True
else:
self(self.dummy_inputs, training=False)
self.built = True
self(self.dummy_inputs, training=False)

def __init__(self, config, *inputs, **kwargs):
super().__init__(*inputs, **kwargs)
Expand Down

0 comments on commit 50ed793

Please sign in to comment.