Skip to content

Commit 4a1cebd

Browse files
AswinossAswinoss
authored andcommitted
fix: Browser stack failures on devices with Qualcomm Soc
* Adding isFatal check in Str2Delegate function * Avoids preliminary crash if the delegate is not available --------- Co-authored-by: Aswin B <[email protected]>
1 parent b38b2e9 commit 4a1cebd

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

mobile_back_qti/cpp/backend_qti/qti_backend_helper.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
#include <random>
1919
#include <string>
2020
#include <vector>
21+
#include <sstream>
2122

2223
#include "DiagLog/IDiagLog.h"
2324
#include "DlContainer/DlContainer.h"
@@ -96,8 +97,9 @@ static Snpe_TensorShape_Handle_t calcStrides(
9697
return tensorShapeHandle;
9798
}
9899

99-
static Snpe_Runtime_t Str2Delegate(const snpe_runtimes_t delegate) {
100+
static Snpe_Runtime_t Str2Delegate(const snpe_runtimes_t delegate, bool isFatal = false) {
100101
Snpe_Runtime_t runtime;
102+
101103
switch (delegate) {
102104
case SNPE_DSP:
103105
runtime = SNPE_RUNTIME_DSP;
@@ -121,8 +123,12 @@ static Snpe_Runtime_t Str2Delegate(const snpe_runtimes_t delegate) {
121123
runtime, SNPE_RUNTIME_CHECK_OPTION_UNSIGNEDPD_CHECK)) {
122124
LOG(INFO) << "runtime " << delegate << " is available on this platform";
123125
} else {
124-
LOG(FATAL) << "runtime " << delegate
125-
<< " is not available on this platform";
126+
std::stringstream log_err_string;
127+
log_err_string << "runtime " << delegate << " is not available on this platform";
128+
if(isFatal)
129+
LOG(FATAL) << log_err_string.str();
130+
else
131+
LOG(ERROR) << log_err_string.str();
126132
}
127133

128134
return runtime;
@@ -713,7 +719,7 @@ void QTIBackendHelper::set_runtime_config() {
713719
Snpe_Runtime_t runtime;
714720
for (int i = 0; i < numDSP; i++) {
715721
if (i == 0) {
716-
runtime = Str2Delegate(SNPE_DSP);
722+
runtime = Str2Delegate(SNPE_DSP, true);
717723
}
718724
auto runtimeConfigHandle = Snpe_RuntimeConfig_Create();
719725

@@ -728,7 +734,7 @@ void QTIBackendHelper::set_runtime_config() {
728734

729735
for (int i = 0; i < numGPU; i++) {
730736
if (i == 0) {
731-
runtime = Str2Delegate(SNPE_GPU);
737+
runtime = Str2Delegate(SNPE_GPU, true);
732738
}
733739
auto runtimeConfigHandle = Snpe_RuntimeConfig_Create();
734740
Snpe_RuntimeConfig_SetRuntime(runtimeConfigHandle, runtime);
@@ -741,7 +747,7 @@ void QTIBackendHelper::set_runtime_config() {
741747

742748
for (int i = 0; i < numCPU; i++) {
743749
if (i == 0) {
744-
runtime = Str2Delegate(SNPE_CPU);
750+
runtime = Str2Delegate(SNPE_CPU, true);
745751
}
746752
auto runtimeConfigHandle = Snpe_RuntimeConfig_Create();
747753
Snpe_RuntimeConfig_SetRuntime(runtimeConfigHandle, runtime);
@@ -875,4 +881,4 @@ void QTIBackendHelper::deinitSd() {
875881
delete sd_pipeline;
876882
sd_pipeline = nullptr;
877883
#endif
878-
}
884+
}}}

0 commit comments

Comments
 (0)