xref: /aosp_15_r20/external/executorch/backends/qualcomm/partition/utils.py (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1# Copyright (c) Qualcomm Innovation Center, Inc.
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
7from typing import List
8
9from executorch.backends.qualcomm.utils.constants import QCOM_QNN_COMPILE_SPEC
10
11from executorch.exir.backend.compile_spec_schema import CompileSpec
12
13
14def generate_qnn_executorch_option(
15    compiler_specs: List[CompileSpec],
16) -> bytes:
17    for compiler_spec in compiler_specs:
18        if compiler_spec.key == QCOM_QNN_COMPILE_SPEC:
19            qnn_compile_spec_buffer = compiler_spec.value
20        else:
21            raise ValueError(f"unknown compiler spec key value: {compiler_spec.key}")
22    return qnn_compile_spec_buffer
23