Runs various checks on the given graph module to make sure it contains the needed data for passes. Some checks that need to be run: - Ensure that types of operator node match the types specified in the node's spec field (ex. if the op returns a tup
(self, module: torch.nn.Module)
| 55 | ) |
| 56 | |
| 57 | def check(self, module: torch.nn.Module) -> None: |
| 58 | """ |
| 59 | Runs various checks on the given graph module to make sure it contains |
| 60 | the needed data for passes. |
| 61 | |
| 62 | Some checks that need to be run: |
| 63 | - Ensure that types of operator node match the types specified in |
| 64 | the node's spec field (ex. if the op returns a tuple then the |
| 65 | node's spec field is a tuple) |
| 66 | - Ensure that the graph module has type torch.fx.GraphModule |
| 67 | """ |
| 68 | assert isinstance(module, fx.GraphModule) |
| 69 | module.recompile() |
| 70 | module.graph.lint() |
| 71 | # TODO(qihan): use verifier.check_is_exir |
| 72 | |
| 73 | for node in module.graph.nodes: |
| 74 | if node.op == "call_method": |
| 75 | raise ExportError( |
| 76 | ExportErrorType.NOT_SUPPORTED, |
| 77 | f"call_method `{node}` is not supported except for backend delegate.", |
| 78 | ) |