[Use cache] Align logic of use_cache with output_attentions and output_hidden_states (#5194)
* fix use cache * add bart use cache * fix bart * finish bart
This commit is contained in:
committed by
GitHub
parent
64c393ee74
commit
c2a26ec8a6
@@ -193,7 +193,14 @@ class T5ModelTester:
|
||||
model.eval()
|
||||
|
||||
# first forward pass
|
||||
output, past_key_value_states = model(input_ids, use_cache=True)
|
||||
outputs = model(input_ids, use_cache=True)
|
||||
outputs_use_cache_conf = model(input_ids)
|
||||
outputs_no_past = model(input_ids, use_cache=False)
|
||||
|
||||
self.parent.assertTrue(len(outputs) == len(outputs_use_cache_conf))
|
||||
self.parent.assertTrue(len(outputs) == len(outputs_no_past) + 1)
|
||||
|
||||
output, past_key_value_states = outputs
|
||||
|
||||
# create hypothetical next token and extent to next_input_ids
|
||||
next_tokens = ids_tensor((self.batch_size, 1), config.vocab_size)
|
||||
|
||||
Reference in New Issue
Block a user