add util to print the delegated graph after delegated (#1846)
Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/1846
Add a way to print the graph with the inlined lowered graph as well as the backend id. Example output
```
graph():
%arg0_1 : [num_users=2] = placeholder[target=arg0_1]
%arg1_1 : [num_users=2] = placeholder[target=arg1_1]
%arg2_1 : [num_users=2] = placeholder[target=arg2_1]
%lowered_module_0 : [num_users=1] = get_attr[target=lowered_module_0]
backend_id: BackendWithCompilerDemo
lowered graph(): %arg0_1 : [num_users=1] = placeholder[target=arg0_1]
%arg1_1 : [num_users=1] = placeholder[target=arg1_1]
%arg2_1 : [num_users=1] = placeholder[target=arg2_1]
%aten_mm_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.mm.default](args = (%arg0_1, %arg1_1), kwargs = {})
%aten_add_tensor : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_mm_default, %arg2_1), kwargs = {})
return [aten_add_tensor]
%executorch_call_delegate : [num_users=1] = call_function[target=torch.ops.higher_order.executorch_call_delegate](args = (%lowered_module_0, %arg0_1, %arg1_1, %arg2_1), kwargs = {})
%getitem : [num_users=1] = call_function[target=operator.getitem](args = (%executorch_call_delegate, 0), kwargs = {})
%aten_sub_tensor : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.sub.Tensor](args = (%getitem, %arg0_1), kwargs = {})
%lowered_module_1 : [num_users=1] = get_attr[target=lowered_module_1]
backend_id: BackendWithCompilerDemo
lowered graph(): %aten_sub_tensor : [num_users=1] = placeholder[target=aten_sub_tensor]
%arg1_1 : [num_users=1] = placeholder[target=arg1_1]
%arg2_1 : [num_users=1] = placeholder[target=arg2_1]
%aten_mm_default_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.mm.default](args = (%aten_sub_tensor, %arg1_1), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_mm_default_1, %arg2_1), kwargs = {})
return [aten_add_tensor_1]
%executorch_call_delegate_1 : [num_users=1] = call_function[target=torch.ops.higher_order.executorch_call_delegate](args = (%lowered_module_1, %aten_sub_tensor, %arg1_1, %arg2_1), kwargs = {})
%getitem_1 : [num_users=1] = call_function[target=operator.getitem](args = (%executorch_call_delegate_1, 0), kwargs = {})
return [getitem_1]
```
Reviewed By: Jack-Khuu
Differential Revision: D53435243
fbshipit-source-id: 3c55a9a2c6d33b78d5a8ba15ee050607b7d1817b C
Chen Lai committed
91bf41996178256a5a480a11d2da77c8598ff8dd
Parent: 3327fca
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 2/6/2024, 1:44:48 AM