(
edge_program: ExportedProgram,
compile_specs: List[CompileSpec],
)
| 103 | class XnnpackBackend(BackendDetails): |
| 104 | @staticmethod |
| 105 | def preprocess( |
| 106 | edge_program: ExportedProgram, |
| 107 | compile_specs: List[CompileSpec], |
| 108 | ) -> PreprocessResult: |
| 109 | named_data_store = NamedDataStore() |
| 110 | xnnpack_edge_compile_config = get_xnnpack_edge_compile_config() |
| 111 | |
| 112 | # Need to wrap EP here because xnnpack does addmm to linear |
| 113 | # transforms. This makes resulting graph not aten compliant |
| 114 | # as aten.linear is not a core aten op. |
| 115 | # Ideal fix would be to have XNNPACK verifier that bypass |
| 116 | # most checks but the base Verifier itself has some strict changes |
| 117 | # and to bypass those, we would basically copy what EdgeDialectVerifier |
| 118 | # does. So for now instead of copy pasting that, just instantiate |
| 119 | # EdgeDialectVerifier, but disable it. |
| 120 | # TODO (task link) to implement NullVerifier or something similar |
| 121 | ep = ExportedProgram( |
| 122 | root=edge_program.graph_module, |
| 123 | graph=edge_program.graph, |
| 124 | graph_signature=edge_program.graph_signature, |
| 125 | state_dict=edge_program.state_dict, |
| 126 | range_constraints=edge_program.range_constraints, |
| 127 | module_call_graph=edge_program.module_call_graph, |
| 128 | example_inputs=edge_program.example_inputs, |
| 129 | constants=edge_program.constants, |
| 130 | verifiers=[ |
| 131 | EXIREdgeDialectVerifier( |
| 132 | edge_compile_config=xnnpack_edge_compile_config, class_only=True |
| 133 | ) |
| 134 | ], |
| 135 | ) |
| 136 | |
| 137 | passes = [] |
| 138 | for spec in compile_specs: |
| 139 | if spec.key == "dqlinear_partitioner": |
| 140 | passes.append(ConvertToLinearPass) |
| 141 | |
| 142 | passes = passes if len(passes) > 0 else None |
| 143 | # XNNPACK Delegate Specific Passes |
| 144 | ep = XNNPACKPassManager(ep, passes=passes).transform() |
| 145 | graph_module = ep.graph_module |
| 146 | |
| 147 | node_to_external_map = generate_node_to_external_map(ep, graph_module) |
| 148 | |
| 149 | # TODO retrace the graph module to lift the new params may have |
| 150 | # been added to the graph in passes |
| 151 | |
| 152 | vals_to_ids = {} |
| 153 | xnnpack_graph = XNNGraph( |
| 154 | version="0", |
| 155 | xnodes=[], |
| 156 | xvalues=[], |
| 157 | num_externs=len(node_to_external_map), |
| 158 | input_ids=[], |
| 159 | output_ids=[], |
| 160 | constant_data=[ConstantDataOffset(0, 0)], |
| 161 | ) |
| 162 |
nothing calls this directly
no test coverage detected