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

[IR] Create predecessors() and successors() on ir.Node #2022

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Jan 18, 2025

  • Also updated Usage to a named tuple
  • Implement consumers() on Value

@justinchuby justinchuby added the topic: IR Intermediate representation label Jan 18, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (5)

onnxscript/ir/_core.py:1314

  • Ensure that value is not None before calling value.producer().
if value is not None and (producer := value.producer()) is not None:

onnxscript/ir/_core.py:1326

  • [nitpick] Consider replacing the assert statement with a more informative error message or exception.
assert value is not None, "Bug: Output values are not expected to be None"

onnxscript/ir/_core.py:1059

  • [nitpick] Consider renaming 'Usage' to 'NodeUsage' for better clarity.
class Usage(NamedTuple):

onnxscript/ir/_core.py:1309

  • Ensure that the 'predecessors' method is covered by tests.
def predecessors(self) -> Sequence[Node]:

onnxscript/ir/_core.py:1321

  • Ensure that the 'successors' method is covered by tests.
def successors(self) -> Sequence[Node]:
onnxscript/ir/_core.py Outdated Show resolved Hide resolved
onnxscript/ir/_core.py Fixed Show fixed Hide fixed
Copy link

codecov bot commented Jan 18, 2025

❌ 70 Tests Failed:

Tests completed Failed Passed Skipped
11840 70 11770 2454
View the top 3 failed tests by shortest run time
onnxscript.backend.onnx_export_test.TestOnnxBackEnd::test_export2python_produces_correct_onnx_script_model_0414_test_gemm_default_scalar_bias
Stack Traces | 0.003s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_gemm_default_scalar_bias'

The above exception was the direct cause of the following exception:
.nox\test_onnx_weekly\Lib\site-packages\parameterized\parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
onnxscript\backend\onnx_export_test.py:271: in test_export2python_produces_correct_onnx_script_model
    functions = extract_functions(backend_test.name, code, self.test_folder)
onnxscript\backend\onnx_export_test.py:139: in extract_functions
    raise AssertionError(
E   AssertionError: Unable to import 'tests.onnx_backend_test_code.test_gemm_default_scalar_bias' (e=No module named 'tests.onnx_backend_test_code.test_gemm_default_scalar_bias') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_gemm_default_scalar_bias.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_gemm_default_scalar_bias.py', current folder: D:\a\onnxscript\onnxscript
E   ---- CONTENT --
E   import numpy
E   from onnx import TensorProto
E   from onnx.helper import make_tensor
E   from onnxscript import script, external_tensor
E   from onnxscript.values import Opset
E   from onnxscript.onnx_types import FLOAT
E   from onnxscript.onnx_opset import opset13
E   
E   @script()
E   def bck_test_gemm_default_scalar_bias(a: FLOAT[2,3], b: FLOAT[3,4], c: FLOAT) -> (FLOAT[2,4]):
E       y = opset13.Gemm(a, b, c)
E       return y
onnxscript.backend.onnx_export_test.TestOnnxBackEnd::test_export2python_produces_correct_onnx_script_model_0988_test_resize_upsample_sizes_nearest_axes_2_3
Stack Traces | 0.003s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_resize_upsample_sizes_nearest_axes_2_3'

The above exception was the direct cause of the following exception:
.nox\test_onnx_weekly\Lib\site-packages\parameterized\parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
onnxscript\backend\onnx_export_test.py:271: in test_export2python_produces_correct_onnx_script_model
    functions = extract_functions(backend_test.name, code, self.test_folder)
onnxscript\backend\onnx_export_test.py:139: in extract_functions
    raise AssertionError(
E   AssertionError: Unable to import 'tests.onnx_backend_test_code.test_resize_upsample_sizes_nearest_axes_2_3' (e=No module named 'tests.onnx_backend_test_code.test_resize_upsample_sizes_nearest_axes_2_3') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_resize_upsample_sizes_nearest_axes_2_3.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_resize_upsample_sizes_nearest_axes_2_3.py', current folder: D:\a\onnxscript\onnxscript
E   ---- CONTENT --
E   import numpy
E   from onnx import TensorProto
E   from onnx.helper import make_tensor
E   from onnxscript import script, external_tensor
E   from onnxscript.values import Opset
E   from onnxscript.onnx_types import FLOAT, INT64
E   from onnxscript.onnx_opset import opset19
E   
E   @script()
E   def bck_test_resize_upsample_sizes_nearest_axes_2_3(X: FLOAT[1,1,2,2], sizes: INT64[2]) -> (FLOAT[1,1,7,8]):
E       Y = opset19.Resize(X, None, None, sizes, axes=[2, 3], mode='nearest')
E       return Y
onnxscript.backend.onnx_export_test.TestOnnxBackEnd::test_export2python_produces_correct_onnx_script_model_1008_test_scatternd_multiply
Stack Traces | 0.003s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_scatternd_multiply'

The above exception was the direct cause of the following exception:
.nox\test_onnx_weekly\Lib\site-packages\parameterized\parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
onnxscript\backend\onnx_export_test.py:271: in test_export2python_produces_correct_onnx_script_model
    functions = extract_functions(backend_test.name, code, self.test_folder)
onnxscript\backend\onnx_export_test.py:139: in extract_functions
    raise AssertionError(
E   AssertionError: Unable to import 'tests.onnx_backend_test_code.test_scatternd_multiply' (e=No module named 'tests.onnx_backend_test_code.test_scatternd_multiply') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_scatternd_multiply.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_scatternd_multiply.py', current folder: D:\a\onnxscript\onnxscript
E   ---- CONTENT --
E   import numpy
E   from onnx import TensorProto
E   from onnx.helper import make_tensor
E   from onnxscript import script, external_tensor
E   from onnxscript.values import Opset
E   from onnxscript.onnx_types import FLOAT, INT64
E   from onnxscript.onnx_opset import opset18
E   
E   @script()
E   def bck_test_scatternd_multiply(data: FLOAT[4,4,4], indices: INT64[2,1], updates: FLOAT[2,4,4]) -> (FLOAT[4,4,4]):
E       y = opset18.ScatterND(data, indices, updates, reduction='mul')
E       return y

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

onnxscript/ir/_core.py Fixed Show fixed Hide fixed
onnxscript/ir/_core.py Fixed Show fixed Hide fixed
@justinchuby justinchuby requested a review from Copilot January 19, 2025 03:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

onnxscript/ir/_core.py:1646

  • The word 'addes' is misspelled. It should be 'adds'.
// This addes a small overhead but is better a user experience than

onnxscript/ir/_core_test.py:817

  • Add a test for the successors method.
    # TODO(justinchuby): Test all methods

onnxscript/ir/_core.py Outdated Show resolved Hide resolved
onnxscript/ir/_core.py Outdated Show resolved Hide resolved
onnxscript/ir/_core.py Outdated Show resolved Hide resolved
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

onnxscript/ir/_core_test.py:834

  • Ensure that the order of nodes in the predecessors method is deterministic and consistent.
self.assertEqual(self.node.predecessors(), ())

onnxscript/ir/_core_test.py:843

  • Ensure that the order of nodes in the successors method is deterministic and consistent.
self.assertEqual(self.node.successors(), (self.node_a, self.node_b))

onnxscript/ir/_core.py Show resolved Hide resolved
onnxscript/ir/_core.py Show resolved Hide resolved
onnxscript/ir/_core.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: IR Intermediate representation
Projects
Development

Successfully merging this pull request may close these issues.

1 participant