fix the runtimeError of in-place operation when use transformers for training

#18
Files changed (1) hide show
  1. modeling_internvl_chat.py +1 -1
modeling_internvl_chat.py CHANGED
@@ -101,7 +101,7 @@ class InternVLChatModel(PreTrainedModel):
101
  return_dict = return_dict if return_dict is not None else self.config.use_return_dict
102
 
103
  image_flags = image_flags.squeeze(-1)
104
- input_embeds = self.language_model.get_input_embeddings()(input_ids)
105
 
106
  vit_embeds = self.extract_feature(pixel_values)
107
  vit_embeds = vit_embeds[image_flags == 1]
 
101
  return_dict = return_dict if return_dict is not None else self.config.use_return_dict
102
 
103
  image_flags = image_flags.squeeze(-1)
104
+ input_embeds = self.language_model.get_input_embeddings()(input_ids).clone()
105
 
106
  vit_embeds = self.extract_feature(pixel_values)
107
  vit_embeds = vit_embeds[image_flags == 1]