Skip to content

Commit 593ba98

Browse files
Merge pull request #3978 from graham0824:dev/weilhuan/fix_soc_info
LiteRT-PiperOrigin-RevId: 820318801
2 parents b3c7943 + 9286ee5 commit 593ba98

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

litert/vendors/qualcomm/compiler/qnn_compiler_plugin_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ TEST(TestQnnPlugin, GetConfigInfo) {
176176
LiteRtParamIndex num_supported_soc_models;
177177
LITERT_ASSERT_OK(LiteRtGetNumCompilerPluginSupportedSocModels(
178178
plugin.get(), &num_supported_soc_models));
179-
ASSERT_EQ(num_supported_soc_models, 9);
179+
ASSERT_EQ(num_supported_soc_models, 10);
180180

181181
const char* config_id;
182182
LITERT_ASSERT_OK(

litert/vendors/qualcomm/core/backends/htp_backend.cc

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,47 @@ bool HtpBackend::Init(const Options& options,
7777
return false;
7878
}
7979

80-
// Soc Info
80+
// Starting from QAIRT 2.39, platform information will be available even when
81+
// this API is called during offline preparation. However, it will always
82+
// return the default SoC info (SM8350). If user specifies a SoC, we will
83+
// override the default.
84+
std::optional<::qnn::SocInfo> soc_info_online;
8185
auto local_qnn_device_platform_info = CreateDevicePlatformInfo();
8286
if (local_qnn_device_platform_info) {
83-
QNN_LOG_INFO("Apply deviceGetPlatformInfo for SoC info.");
84-
auto soc_info_online = FindSocInfo(static_cast<::qnn::SnapdragonModel>(
85-
local_qnn_device_platform_info->v1.hwDevices->v1.deviceInfoExtension
86-
->onChipDevice.socModel));
87-
if (soc_info_online.has_value()) {
88-
soc_info_ = *soc_info_online;
89-
}
87+
auto online_soc_model = local_qnn_device_platform_info->v1.hwDevices->v1
88+
.deviceInfoExtension->onChipDevice.socModel;
89+
soc_info_online =
90+
FindSocInfo(static_cast<::qnn::SnapdragonModel>(online_soc_model));
91+
QNN_LOG_INFO(
92+
"Succssfully get platform info. SoC model: %d. SoC name: %s.",
93+
online_soc_model,
94+
soc_info_online.has_value() ? soc_info_online->soc_name : "NotFound");
95+
}
96+
97+
#if defined(__ANDROID__)
98+
if (soc_info_online.has_value()) {
99+
QNN_LOG_INFO("Using online SoC info. SoC name: %s.",
100+
soc_info_online->soc_name);
101+
soc_info_ = *soc_info_online;
90102
} else if (soc_info.has_value()) {
91-
QNN_LOG_INFO("Using provided SoC info.");
103+
QNN_LOG_INFO("Using provided SoC info. SoC name: %s.", soc_info->soc_name);
92104
soc_info_ = *soc_info;
93105
} else {
94-
QNN_LOG_WARNING("Fail to get platforminfo, using default.");
106+
QNN_LOG_WARNING("Fail to get SoC info, using default.");
95107
}
108+
#else
109+
if (soc_info.has_value()) {
110+
QNN_LOG_INFO("Using provided SoC info. SoC name: %s.", soc_info->soc_name);
111+
soc_info_ = *soc_info;
112+
} else if (soc_info_online.has_value()) {
113+
QNN_LOG_INFO("Using online SoC info. SoC name: %s.",
114+
soc_info_online->soc_name);
115+
soc_info_ = *soc_info_online;
116+
} else {
117+
QNN_LOG_WARNING("Fail to get SoC info, using default.");
118+
}
119+
#endif
120+
96121
QNN_LOG_INFO("Initializing QNN backend for SoC model: %s",
97122
soc_info_.soc_name);
98123

litert/vendors/qualcomm/core/schema/soc_table.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ constexpr SocInfo kSocInfos[] = {
3333
{SocInfo("SM8750", SnapdragonModel::SM8750, DspArch::V79,
3434
8 // vtcm_size_in_mb
3535
)},
36+
{SocInfo("SM8850", SnapdragonModel::SM8850, DspArch::V81,
37+
8 // vtcm_size_in_mb
38+
)},
3639
};
3740
constexpr uint64_t kNumSocInfos =
3841
sizeof(::qnn::kSocInfos) / sizeof(::qnn::kSocInfos[0]);

litert/vendors/qualcomm/core/schema/soc_table.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ enum class SnapdragonModel {
1515
SM8550 = 43,
1616
SA8255 = 52,
1717
SM8650 = 57,
18-
SM8750 = 69
18+
SM8750 = 69,
19+
SM8850 = 87,
1920
};
2021

2122
enum class DspArch {
@@ -27,6 +28,7 @@ enum class DspArch {
2728
V73 = 73, // HTP supported device
2829
V75 = 75, // HTP supported device
2930
V79 = 79, // HTP supported device
31+
V81 = 81, // HTP supported device
3032
};
3133

3234
struct SocInfo {

0 commit comments

Comments
 (0)