INNER CODE UNIT · Python
pad_len
OpenVGLab/OmniLottie · app.py:200
pad_len = target_len - input_ids.shape[1]
input_ids = torch.cat([
torch.full((1, pad_len), PAD_TOKEN, dtype=torch.long),
input_ids
], dim=1)
attention_mask = torch.cat([
torch.zeros((1, pad_len), dtype=torch.long),
attention_mask
], dim=1)
result = {
'input_ids': input_ids.to(device),
'attention_mask': attention_mask.to(device),
'pixel_values': inputs.get('pixel_values').to(device) if inputs.get('pixel_values') is not None else None,
'image_grid_thw': inputs.get('image_grid_thw').to(device) if inputs.get('image_grid_thw') is not None else None,
'pixel_values_videos': inputs.get('pixel_values_videos').to(device) if inputs.get('pixel_values_videos') is not None else None,
'video_grid_thw': inputs.get('video_grid_thw').to(device) if inputs.get('video_grid_thw') is not None else None,
}