Skip to content

fix: validator introduced in #4132#4136

Open
narendasan wants to merge 2 commits intomainfrom
narendasan/push-spolrkvvqzlu
Open

fix: validator introduced in #4132#4136
narendasan wants to merge 2 commits intomainfrom
narendasan/push-spolrkvvqzlu

Conversation

@narendasan
Copy link
Collaborator

Description

For cases where the index is an attribute of the graph module, t…he validator should detect this and check that attribute val rather than pass through silently

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • 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

@meta-cla meta-cla bot added the cla signed label Mar 18, 2026
…he validator should detect this and check that attribute val rather than pass through silently
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Mar 18, 2026
@github-actions github-actions bot requested a review from zewenli98 March 18, 2026 22:27
@narendasan narendasan force-pushed the narendasan/push-spolrkvvqzlu branch from b250487 to 2892456 Compare March 18, 2026 22:27
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_index_bool_split_aten.py	2026-03-18 22:27:08.373651+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_index_bool_split_aten.py	2026-03-18 22:27:26.491036+00:00
@@ -4,10 +4,11 @@
1. `index_has_bool_indices` validator correctly distinguishes bool vs int indices.
2. Integer-indexed `aten.index.Tensor` routes to the converter WITHOUT output allocator.
3. Boolean-indexed `aten.index.Tensor` routes to the converter WITH output allocator.
4. Both paths produce correct results.
"""
+
import unittest
from unittest.mock import MagicMock

import torch
import torch.nn as nn
@@ -58,13 +59,11 @@
        node = _make_index_node([None, torch.tensor([True, False])])
        self.assertTrue(index_has_bool_indices(node))

    def test_mixed_int_and_bool_returns_true(self):
        """If any index is bool, the function should return True."""
-        node = _make_index_node(
-            [torch.tensor([0, 1]), torch.tensor([True, False])]
-        )
+        node = _make_index_node([torch.tensor([0, 1]), torch.tensor([True, False])])
        self.assertTrue(index_has_bool_indices(node))

    def test_all_none_returns_false(self):
        node = _make_index_node([None, None])
        self.assertFalse(index_has_bool_indices(node))

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_index_bool_split_aten.py	2026-03-18 22:27:34.043918+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_index_bool_split_aten.py	2026-03-18 22:27:53.739982+00:00
@@ -4,10 +4,11 @@
1. `index_has_bool_indices` validator correctly distinguishes bool vs int indices.
2. Integer-indexed `aten.index.Tensor` routes to the converter WITHOUT output allocator.
3. Boolean-indexed `aten.index.Tensor` routes to the converter WITH output allocator.
4. Both paths produce correct results.
"""
+
import unittest
from unittest.mock import MagicMock

import torch
import torch.nn as nn
@@ -58,13 +59,11 @@
        node = _make_index_node([None, torch.tensor([True, False])])
        self.assertTrue(index_has_bool_indices(node))

    def test_mixed_int_and_bool_returns_true(self):
        """If any index is bool, the function should return True."""
-        node = _make_index_node(
-            [torch.tensor([0, 1]), torch.tensor([True, False])]
-        )
+        node = _make_index_node([torch.tensor([0, 1]), torch.tensor([True, False])])
        self.assertTrue(index_has_bool_indices(node))

    def test_all_none_returns_false(self):
        node = _make_index_node([None, None])
        self.assertFalse(index_has_bool_indices(node))

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_index_bool_split_aten.py	2026-03-18 22:27:52.852046+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_index_bool_split_aten.py	2026-03-18 22:28:13.341265+00:00
@@ -4,10 +4,11 @@
1. `index_has_bool_indices` validator correctly distinguishes bool vs int indices.
2. Integer-indexed `aten.index.Tensor` routes to the converter WITHOUT output allocator.
3. Boolean-indexed `aten.index.Tensor` routes to the converter WITH output allocator.
4. Both paths produce correct results.
"""
+
import unittest
from unittest.mock import MagicMock

import torch
import torch.nn as nn
@@ -58,13 +59,11 @@
        node = _make_index_node([None, torch.tensor([True, False])])
        self.assertTrue(index_has_bool_indices(node))

    def test_mixed_int_and_bool_returns_true(self):
        """If any index is bool, the function should return True."""
-        node = _make_index_node(
-            [torch.tensor([0, 1]), torch.tensor([True, False])]
-        )
+        node = _make_index_node([torch.tensor([0, 1]), torch.tensor([True, False])])
        self.assertTrue(index_has_bool_indices(node))

    def test_all_none_returns_false(self):
        node = _make_index_node([None, None])
        self.assertFalse(index_has_bool_indices(node))

Copy link
Collaborator

@zewenli98 zewenli98 left a comment

Choose a reason for hiding this comment

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

The L0 errors seem not related to this PR. LGTM.

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: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants