@@ -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
0 commit comments