Skip to content

Commit 0ee583e

Browse files
committed
[snpe] Add performance profile configuration support
usage:`... custom=Runtime:DSP,...,PerfProfile:"burst" ...`" - Add support for configuring SNPE performance profiles through custom properties. - The default performance profile is set to 'BALANCED' REF: ``` typedef enum { SNPE_PERFORMANCE_PROFILE_DEFAULT = 0, SNPE_PERFORMANCE_PROFILE_BALANCED = 0, SNPE_PERFORMANCE_PROFILE_HIGH_PERFORMANCE = 1, SNPE_PERFORMANCE_PROFILE_POWER_SAVER = 2, SNPE_PERFORMANCE_PROFILE_SYSTEM_SETTINGS = 3, SNPE_PERFORMANCE_PROFILE_SUSTAINED_HIGH_PERFORMANCE = 4, SNPE_PERFORMANCE_PROFILE_BURST = 5, SNPE_PERFORMANCE_PROFILE_LOW_POWER_SAVER = 6, SNPE_PERFORMANCE_PROFILE_HIGH_POWER_SAVER = 7, SNPE_PERFORMANCE_PROFILE_LOW_BALANCED = 8, SNPE_PERFORMANCE_PROFILE_EXTREME_POWER_SAVER = 9, } Snpe_PerformanceProfile_t; ``` Signed-off-by: Yongjoo Ahn <yongjoo1.ahn@samsung.com>
1 parent f1b3bfd commit 0ee583e

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

src/hal-backend-ml-snpe.cc

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
196196
/* default runtime is CPU */
197197
Snpe_Runtime_t runtime = SNPE_RUNTIME_CPU;
198198

199+
/* default performance profile is 'BALANCED' */
200+
Snpe_PerformanceProfile_t perfProfile = SNPE_PERFORMANCE_PROFILE_BALANCED;
201+
202+
Snpe_Util_InitializeLogging (SNPE_LOG_LEVEL_INFO);
203+
199204
/* lambda function to handle tensor */
200205
auto handleTensor = [&] (const char *tensorName, GstTensorInfo *info,
201206
Snpe_UserBufferMap_Handle_t bufferMapHandle,
@@ -283,7 +288,7 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
283288
};
284289

285290
auto parse_custom_prop = [&runtime, &outputstrListHandle, &inputTypeVec,
286-
&outputTypeVec] (const char *custom_prop) {
291+
&outputTypeVec, &perfProfile] (const char *custom_prop) {
287292
if (!custom_prop)
288293
return;
289294

@@ -355,6 +360,36 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
355360
}
356361
}
357362
g_strfreev (types);
363+
} else if (g_ascii_strcasecmp (option[0], "PerfProfile") == 0) {
364+
bool _valid = true;
365+
if (g_ascii_strcasecmp (option[1], "BALANCED") == 0) {
366+
perfProfile = SNPE_PERFORMANCE_PROFILE_BALANCED;
367+
} else if (g_ascii_strcasecmp (option[1], "HIGH_PERFORMANCE") == 0) {
368+
perfProfile = SNPE_PERFORMANCE_PROFILE_HIGH_PERFORMANCE;
369+
} else if (g_ascii_strcasecmp (option[1], "POWER_SAVER") == 0) {
370+
perfProfile = SNPE_PERFORMANCE_PROFILE_POWER_SAVER;
371+
} else if (g_ascii_strcasecmp (option[1], "SYSTEM_SETTINGS") == 0) {
372+
perfProfile = SNPE_PERFORMANCE_PROFILE_SYSTEM_SETTINGS;
373+
} else if (g_ascii_strcasecmp (option[1], "SUSTAINED_HIGH_PERFORMANCE") == 0) {
374+
perfProfile = SNPE_PERFORMANCE_PROFILE_SUSTAINED_HIGH_PERFORMANCE;
375+
} else if (g_ascii_strcasecmp (option[1], "BURST") == 0) {
376+
perfProfile = SNPE_PERFORMANCE_PROFILE_BURST;
377+
} else if (g_ascii_strcasecmp (option[1], "LOW_POWER_SAVER") == 0) {
378+
perfProfile = SNPE_PERFORMANCE_PROFILE_LOW_POWER_SAVER;
379+
} else if (g_ascii_strcasecmp (option[1], "HIGH_POWER_SAVER") == 0) {
380+
perfProfile = SNPE_PERFORMANCE_PROFILE_HIGH_POWER_SAVER;
381+
} else if (g_ascii_strcasecmp (option[1], "LOW_BALANCED") == 0) {
382+
perfProfile = SNPE_PERFORMANCE_PROFILE_LOW_BALANCED;
383+
} else if (g_ascii_strcasecmp (option[1], "EXTREME_POWER_SAVER") == 0) {
384+
perfProfile = SNPE_PERFORMANCE_PROFILE_EXTREME_POWER_SAVER;
385+
} else {
386+
_valid = false;
387+
g_warning ("Unknown performance profile (%s), set BALANCED as default.",
388+
options[op]);
389+
}
390+
391+
if (_valid)
392+
g_info ("Set performance profile to %s", option[1]);
358393
} else {
359394
g_warning ("Unknown option (%s).", options[op]);
360395
}
@@ -428,6 +463,10 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
428463
}
429464
}
430465

466+
/* Set Perfornamce Profile */
467+
if (Snpe_SNPEBuilder_SetPerformanceProfile (snpebuilder_h, perfProfile) != SNPE_SUCCESS)
468+
throw std::runtime_error ("Failed to set performance profile");
469+
431470
snpe->snpe_h = Snpe_SNPEBuilder_Build (snpebuilder_h);
432471
if (!snpe->snpe_h)
433472
throw std::runtime_error ("Failed to build SNPE handle");

0 commit comments

Comments
 (0)