(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None)
| 715 | |
| 716 | |
| 717 | def encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None): |
| 718 | text_input_ids = input_ids.to(text_encoder.device) |
| 719 | |
| 720 | if text_encoder_use_attention_mask: |
| 721 | attention_mask = attention_mask.to(text_encoder.device) |
| 722 | else: |
| 723 | attention_mask = None |
| 724 | |
| 725 | prompt_embeds = text_encoder( |
| 726 | text_input_ids, |
| 727 | attention_mask=attention_mask, |
| 728 | return_dict=False, |
| 729 | ) |
| 730 | prompt_embeds = prompt_embeds[0] |
| 731 | |
| 732 | return prompt_embeds |
| 733 | |
| 734 | |
| 735 | def main(args): |
no test coverage detected