[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
@@ -143,7 +143,14 @@ class TFGPT2ModelTester:
|
||||
model = TFGPT2Model(config=config)
|
||||
|
||||
# first forward pass
|
||||
output, past = model(input_ids, token_type_ids=token_type_ids)
|
||||
outputs = model(input_ids, token_type_ids=token_type_ids, use_cache=True)
|
||||
outputs_use_cache_conf = model(input_ids, token_type_ids=token_type_ids)
|
||||
outputs_no_past = model(input_ids, token_type_ids=token_type_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 = 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