1 /*
2  * Copyright (c) Qualcomm Innovation Center, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 #pragma once
9 
10 #include <executorch/backends/qualcomm/qc_compiler_spec_generated.h>
11 
12 #include <memory>
13 #include <vector>
14 
15 #include "HTP/QnnHtpDevice.h"
16 namespace executorch {
17 namespace backends {
18 namespace qnn {
19 using namespace qnn_delegate;
20 class HtpDevicePlatformInfoConfig {
21  public:
HtpDevicePlatformInfoConfig(const QnnExecuTorchHtpBackendOptions * htp_options)22   explicit HtpDevicePlatformInfoConfig(
23       const QnnExecuTorchHtpBackendOptions* htp_options)
24       : htp_options_(htp_options) {}
25   std::vector<QnnDevice_PlatformInfo_t*> CreateDevicePlatformInfo(
26       const SocInfo* qcom_target_soc_info);
27 
28  private:
AllocDevicePlatformInfo()29   QnnDevice_PlatformInfo_t* AllocDevicePlatformInfo() {
30     htp_platform_info_.emplace_back(
31         std::make_unique<QnnDevice_PlatformInfo_t>());
32     htp_platform_info_.back()->version =
33         QNN_DEVICE_PLATFORM_INFO_VERSION_UNDEFINED;
34     return htp_platform_info_.back().get();
35   }
36 
AllocHwDeviceInfo()37   QnnDevice_HardwareDeviceInfo_t* AllocHwDeviceInfo() {
38     htp_hw_device_info_.emplace_back(
39         std::make_unique<QnnDevice_HardwareDeviceInfo_t>());
40     htp_hw_device_info_.back()->version =
41         QNN_DEVICE_HARDWARE_DEVICE_INFO_VERSION_UNDEFINED;
42     return htp_hw_device_info_.back().get();
43   }
44 
AllocCoreInfo()45   QnnDevice_CoreInfo_t* AllocCoreInfo() {
46     htp_core_info_.emplace_back(std::make_unique<QnnDevice_CoreInfo_t>());
47     htp_core_info_.back()->version = QNN_DEVICE_CORE_INFO_VERSION_UNDEFINED;
48     return htp_core_info_.back().get();
49   }
50 
AllocDeviceInfoExtension()51   QnnHtpDevice_DeviceInfoExtension_t* AllocDeviceInfoExtension() {
52     htp_device_info_extension_.emplace_back(
53         std::make_unique<QnnHtpDevice_DeviceInfoExtension_t>());
54     htp_device_info_extension_.back()->devType = QNN_HTP_DEVICE_TYPE_UNKNOWN;
55     return htp_device_info_extension_.back().get();
56   }
57 
58   [[maybe_unused]] const QnnExecuTorchHtpBackendOptions* htp_options_;
59 
60   std::vector<std::unique_ptr<QnnDevice_PlatformInfo_t>> htp_platform_info_;
61   std::vector<std::unique_ptr<QnnDevice_HardwareDeviceInfo_t>>
62       htp_hw_device_info_;
63   std::vector<std::unique_ptr<QnnDevice_CoreInfo_t>> htp_core_info_;
64   std::vector<std::unique_ptr<QnnHtpDevice_DeviceInfoExtension_t>>
65       htp_device_info_extension_;
66 };
67 } // namespace qnn
68 } // namespace backends
69 } // namespace executorch
70