Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Torch] Fix bugs for Torch::AtenOneHotOp #3350

Merged
merged 2 commits into from
May 22, 2024

Conversation

angelz913
Copy link
Collaborator

@angelz913 angelz913 commented May 15, 2024

This PR fixes the bugs for Torch::AtenOneHotOp by:

  1. Using Torch::kUnknownSize as the default value for numClasses in
    the pattern matching stage in DecomposeAtenOneHotOp
  2. Adding AtenIntScalarOp to the patterns in TorchToArith
  3. Handling both int and float types for off and on values in TorchOnnxToTorch conversion

It also includes:

  1. A new test in TorchToArith/basic.mlir, for torch.aten.Int.Scalar, and
  2. A new test in decompose-complex-ops.mlir, for torch.aten.one_hot

Dependencies

This PR is dependent on #3334.

@angelz913 angelz913 requested review from rsuderman, vivekkhandelwal1 and renxida and removed request for rsuderman May 15, 2024 21:06
Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

Are we able to write LIT tests for these?

test/Conversion/TorchToLinalg/onehot.mlir Outdated Show resolved Hide resolved
test/Conversion/TorchToLinalg/onehot.mlir Outdated Show resolved Hide resolved
test/Conversion/TorchToLinalg/onehot.mlir Outdated Show resolved Hide resolved
test/Conversion/TorchToLinalg/onehot.mlir Outdated Show resolved Hide resolved
test/Conversion/TorchToLinalg/onehot.mlir Outdated Show resolved Hide resolved
lib/Conversion/TorchToArith/TorchToArith.cpp Show resolved Hide resolved
Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

LGTM

@kuhar kuhar requested a review from qedawkins May 17, 2024 21:15
@kuhar
Copy link
Member

kuhar commented May 17, 2024

@qedawkins can you take another look and merge if everything's addressed?

Copy link
Collaborator

@qedawkins qedawkins left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@qedawkins
Copy link
Collaborator

Looks like the CI is failing for some reason. I can help merge after that's fixed.

@renxida renxida enabled auto-merge (squash) May 18, 2024 03:54
@renxida
Copy link
Collaborator

renxida commented May 18, 2024

automerge enabled. Fix the CI and we're good to go!

@kuhar kuhar disabled auto-merge May 21, 2024 14:20
@angelz913 angelz913 force-pushed the one-hot-torch-to-linalg-fix branch 7 times, most recently from d831391 to 7415983 Compare May 21, 2024 22:47
This commit fixes bugs for the onnx.OneHot operator by:

1) Converting negative indices to non-negative indices
2) Handling both int and float types for off and on values
3) Using the correct result type

It also includes a new unit test.
This commit fixes the bugs for Torch::AtenOneHotOp by:

1. Using Torch::kUnknownSize as the default value for numClasses in
   the pattern matching stage for DecomposeAtenOneHotOp
2. Adding AtenIntScalarOp to the patterns in TorchToArith
3. Handling both int and float types for off and on values in ONNX to
   Torch conversion

It also includes:

1. A new test in TorchToArith/basic.mlir, for torch.aten.Int.Scalar, and
2. A new test in decompose-complex-ops.mlir, for torch.aten.one_hot
@angelz913 angelz913 force-pushed the one-hot-torch-to-linalg-fix branch from 7415983 to 4c58e11 Compare May 22, 2024 16:56
@kuhar kuhar enabled auto-merge (squash) May 22, 2024 17:00
@kuhar kuhar merged commit 2e194e1 into llvm:main May 22, 2024
3 checks passed
BaneTrifa pushed a commit to BaneTrifa/torch-mlir that referenced this pull request May 24, 2024
This PR fixes the bugs for `Torch::AtenOneHotOp` by:

1) Using `Torch::kUnknownSize` as the default value for `numClasses` in
   the pattern matching stage in `DecomposeAtenOneHotOp`
2) Adding `AtenIntScalarOp` to the patterns in `TorchToArith`
3) Handling both `int` and `float` types for `off` and `on` values in
`TorchOnnxToTorch` conversion

It also includes:

1) A new test in `TorchToArith/basic.mlir`, for `torch.aten.Int.Scalar`,
and
2) A new test in `decompose-complex-ops.mlir`, for `torch.aten.one_hot`

**Dependencies**

This PR is dependent on llvm#3334.
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.

None yet

4 participants