Skip to content

fix: aten.index converter #2487

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

Merged
merged 2 commits into from
Dec 12, 2023

Conversation

zewenli98
Copy link
Collaborator

Description

See details in the issue below.

Fixes #2480

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Nov 28, 2023
@github-actions github-actions bot requested a review from apbose November 28, 2023 02:04
Copy link
Collaborator

@apbose apbose left a comment

Choose a reason for hiding this comment

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

Looks good!

@dynamo_tensorrt_converter(torch.ops.aten.index.Tensor)
def index_dtype_validator(node: Node) -> bool:
index = node.args[1]
return all(ind.meta["val"].dtype == torch.int32 for ind in index if ind is not None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use get for dictionary

@gs-olive gs-olive requested a review from peri044 December 1, 2023 19:08
@zewenli98 zewenli98 requested a review from gs-olive December 5, 2023 00:59
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

It seems that the bug in #2480 is only related to the fact that our index converter cannot handle boolean mask indices. The fact that the example has data-dependent shapes does not seem to be the root cause of the initial error.

This is a good temporary fix. Could you also file an issue which specifies that we need to expand index support to boolean masks, since this is a valid usage in Torch and we already support something very similar in aten.where, we just need to add the functionality here. See the sample case below:

>>> import torch
>>> y = torch.rand(2, 2)
>>> y
tensor([[0.3105, 0.9580],
        [0.4824, 0.0796]])
>>> y[torch.Tensor([[True, True], [False, False]]).bool()]
tensor([0.3105, 0.9580])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] aten.index converter doesn't work when index is a TRTTensor
4 participants