Skip to content

[IR] Unsupported slice and ellipsis indexes to iter a graph #2302

Closed
@Johansmm

Description

@Johansmm

Code to reproduce the error:

import onnx
from onnxscript import ir

model = onnx.parser.parse_model(
"""<ir_version: 10, opset_import: [ "" : 17]>
     agraph (float[N] x) => (float[N] z) {
         y = Sigmoid(x)
         z = Mul(y, y)  
     }""")
ir_model = ir.from_proto(model)
ir_model.graph[0:]

Error logs

Errors when executing ir_model.graph[0:]:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "onnxscript\ir\_core.py", line 2232, in __getitem__
    return self._nodes[index]
           ~~~~~~~~~~~^^^^^^^
  File "onnxscript\ir\_linked_list.py", line 144, in __getitem__
    if index >= self._length or index < -self._length:
       ^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'slice' and 'int'

Activity

justinchuby

justinchuby commented on May 13, 2025

@justinchuby
Collaborator

Contributions welcomed! In the meantime, consider

nodes = tuple(model.graph)

Then take slices on the nodes

added a commit that references this issue on May 22, 2025
6d5a135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @justinchuby@Johansmm

      Issue actions

        [IR] Unsupported slice and ellipsis indexes to iter a graph · Issue #2302 · microsoft/onnxscript