Skip to content

Support item() and related shape assertion operators #299

@dayo09

Description

@dayo09

What?

Let's support below torch graph.

class SimpleItem(TestModuleBase):
    def __init__(self):
        super().__init__()

    def forward(self, x, y):
        return x.item() + y

    def get_example_inputs(self):
        return (torch.tensor(1), 2), {}
opcode         name                    target                       args                                                                  kwargs
-------------  ----------------------  ---------------------------  --------------------------------------------------------------------  --------
placeholder    x                       x                            ()                                                                    {}
placeholder    y                       y                            ()                                                                    {}
call_function  item                    aten.item.default            (x,)                                                                  {}
call_function  ge                      <built-in function ge>       (item, 2)                                                             {}
call_function  _assert_scalar_default  aten._assert_scalar.default  (ge, "Runtime assertion failed for expression u0 >= 2 on node 'ge'")  {}
call_function  add                     <built-in function add>      (item, 2)                                                             {}
output         output                  output                       ((add,),)                                                             {}
ERROR:tico.utils.convert:NOT SUPPORTED OPERATOR
        (op) item.default
        (trace)   File "/home/dayoung.lee/git/TICO/test/modules/op/item.py", line 25, in forward
    return x.item() + y

ERROR:tico.utils.convert:NOT SUPPORTED OPERATOR
        (op) ge
        (trace)   File "/home/dayoung.lee/git/TICO/test/modules/op/item.py", line 25, in forward
    return x.item() + y

ERROR:tico.utils.convert:NOT SUPPORTED OPERATOR
        (op) _assert_scalar.default
        (trace)   File "/home/dayoung.lee/git/TICO/test/modules/op/item.py", line 25, in forward
    return x.item() + y

ERROR:tico.utils.convert:NOT SUPPORTED OPERATOR
        (op) add
        (trace)   File "/home/dayoung.lee/git/TICO/test/modules/op/item.py", line 25, in forward
    return x.item() + y


TEST FAILED at 'convert_pt2_to_circle ...'
 NOT SUPPORTED OPERATOR IN GRAPH MODULE
ERROR

My simple plan is to remove assertion operators from remove_nop pass and remove dangling builtin ops.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions