(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None)
| 786 | |
| 787 | |
| 788 | def encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None): |
| 789 | text_input_ids = input_ids.to(text_encoder.device) |
| 790 | |
| 791 | if text_encoder_use_attention_mask: |
| 792 | attention_mask = attention_mask.to(text_encoder.device) |
| 793 | else: |
| 794 | attention_mask = None |
| 795 | |
| 796 | prompt_embeds = text_encoder( |
| 797 | text_input_ids, |
| 798 | attention_mask=attention_mask, |
| 799 | return_dict=False, |
| 800 | ) |
| 801 | prompt_embeds = prompt_embeds[0] |
| 802 | |
| 803 | return prompt_embeds |
| 804 | |
| 805 | |
| 806 | def main(args): |
no test coverage detected