Unverified Commit cb2b0276 authored by Zhaofeng Wu's avatar Zhaofeng Wu Committed by GitHub
Browse files

Change assertion to warning when passing past_key_value to T5 encoder (#16153)

* Change assertion to warning when passing past_key_value to T5 encoder

* lint
parent ecb4662d
...@@ -648,7 +648,8 @@ class T5Block(nn.Module): ...@@ -648,7 +648,8 @@ class T5Block(nn.Module):
): ):
if past_key_value is not None: if past_key_value is not None:
assert self.is_decoder, "Only decoder can use `past_key_values`" if not self.is_decoder:
logger.warning("`past_key_values` is passed to the encoder. Please make sure this is intended.")
expected_num_past_key_values = 2 if encoder_hidden_states is None else 4 expected_num_past_key_values = 2 if encoder_hidden_states is None else 4
if len(past_key_value) != expected_num_past_key_values: if len(past_key_value) != expected_num_past_key_values:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment