Skip to content

[FIX][Relax] Promote mixed input types when importing torch.cat - #21128

Open
GeekyKartikey wants to merge 1 commit into
apache:mainfrom
GeekyKartikey:fix/torch-cat-type-promotion
Open

GeekyKartikey wants to merge 1 commit into
apache:mainfrom
GeekyKartikey:fix/torch-cat-type-promotion

Conversation

@GeekyKartikey

Copy link
Copy Markdown

Fixes #20920

PyTorch accepts a bool tensor and an int64 tensor in the same torch.cat call and returns int64. Importing the exported model failed because Relax expects every input to concat to have the same type.

I updated the importer to use PyTorch’s promotion rules across all the inputs. It only casts tensors whose type needs to change before calling concat.

The new tests compare both the values and the output type with PyTorch. They cover three pairs of input types and one case with three different types.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Relax] torch.cat of tensors with different dtypes fails in from_exported_program: "Concat expects all input tensors to have the same dtype"

1 participant