Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/models/llava/export_llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, llava):
super().__init__()
self.text_model = llava.text_model

def forward(self, input_pos, embeddings):
def forward(self, embeddings, input_pos):
return self.text_model(None, {"input_pos": input_pos}, embeddings)

llava_text_model = LlavaTextModel(llava)
Expand All @@ -88,7 +88,7 @@ def forward(self, input_pos, embeddings):
max_seq_len=llava.text_model_args.max_seq_len,
dtype=DType.fp32,
use_kv_cache=True,
example_inputs=(torch.tensor([0], dtype=torch.int64), embeddings),
example_inputs=(embeddings, torch.tensor([0], dtype=torch.int64)),
dynamic_shapes=dynamic_shapes,
)

Expand Down
2 changes: 1 addition & 1 deletion examples/models/llava/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,5 @@ def _get_image_dynamic_shapes(self):

def _get_prompt_dynamic_shapes(self):
dim = torch.export.Dim("token_dim", min=2, max=self.max_seq_len)
text_model_dynamic_shapes = ({0: 1}, {1: dim})
text_model_dynamic_shapes = ({1: dim}, {0: 1})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 1 and 0 are the dims of a single tensor. So swapping doesnt do anything

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also do you even have to specify that the batch is static 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{0:1} is the dynamic shapes for the first arg, {1:dim} is for the second arg, so I swap them here

return text_model_dynamic_shapes
Loading