xref: /aosp_15_r20/external/executorch/exir/backend/test/qnn_backend_demo.py (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the BSD-style license found in the
5# LICENSE file in the root directory of this source tree.
6
7# The fake qnnback
8from typing import final, List
9
10from executorch.exir.backend.backend_details import (
11    BackendDetails,
12    ExportedProgram,
13    PreprocessResult,
14)
15from executorch.exir.backend.compile_spec_schema import CompileSpec
16
17
18@final
19class QnnBackend(BackendDetails):
20    @staticmethod
21    def preprocess(
22        edge_program: ExportedProgram,
23        compile_specs: List[CompileSpec],
24    ) -> PreprocessResult:
25        processed_bytes = "imqnncompiled"
26        all_nodes_debug_handle = [
27            node.meta["debug_handle"] for node in edge_program.graph.nodes
28        ]
29        return PreprocessResult(
30            processed_bytes=bytes(processed_bytes, encoding="utf8"),
31            # Assuming all nodes are fused as one op
32            debug_handle_map={1: tuple(all_nodes_debug_handle)},
33        )
34