Skip to content

Commit 58667d4

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 db7217f commit 58667d4

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

src/hal-backend-ml-snpe.cc

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ 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+
199202
/* lambda function to handle tensor */
200203
auto handleTensor = [&] (const char *tensorName, GstTensorInfo *info,
201204
Snpe_UserBufferMap_Handle_t bufferMapHandle,
@@ -283,7 +286,7 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
283286
};
284287

285288
auto parse_custom_prop = [&runtime, &outputstrListHandle, &inputTypeVec,
286-
&outputTypeVec] (const char *custom_prop) {
289+
&outputTypeVec, &perfProfile] (const char *custom_prop) {
287290
if (!custom_prop)
288291
return;
289292

@@ -355,6 +358,36 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
355358
}
356359
}
357360
g_strfreev (types);
361+
} else if (g_ascii_strcasecmp (option[0], "PerfProfile") == 0) {
362+
bool _valid = true;
363+
if (g_ascii_strcasecmp (option[1], "BALANCED") == 0) {
364+
perfProfile = SNPE_PERFORMANCE_PROFILE_BALANCED;
365+
} else if (g_ascii_strcasecmp (option[1], "HIGH_PERFORMANCE") == 0) {
366+
perfProfile = SNPE_PERFORMANCE_PROFILE_HIGH_PERFORMANCE;
367+
} else if (g_ascii_strcasecmp (option[1], "POWER_SAVER") == 0) {
368+
perfProfile = SNPE_PERFORMANCE_PROFILE_POWER_SAVER;
369+
} else if (g_ascii_strcasecmp (option[1], "SYSTEM_SETTINGS") == 0) {
370+
perfProfile = SNPE_PERFORMANCE_PROFILE_SYSTEM_SETTINGS;
371+
} else if (g_ascii_strcasecmp (option[1], "SUSTAINED_HIGH_PERFORMANCE") == 0) {
372+
perfProfile = SNPE_PERFORMANCE_PROFILE_SUSTAINED_HIGH_PERFORMANCE;
373+
} else if (g_ascii_strcasecmp (option[1], "BURST") == 0) {
374+
perfProfile = SNPE_PERFORMANCE_PROFILE_BURST;
375+
} else if (g_ascii_strcasecmp (option[1], "LOW_POWER_SAVER") == 0) {
376+
perfProfile = SNPE_PERFORMANCE_PROFILE_LOW_POWER_SAVER;
377+
} else if (g_ascii_strcasecmp (option[1], "HIGH_POWER_SAVER") == 0) {
378+
perfProfile = SNPE_PERFORMANCE_PROFILE_HIGH_POWER_SAVER;
379+
} else if (g_ascii_strcasecmp (option[1], "LOW_BALANCED") == 0) {
380+
perfProfile = SNPE_PERFORMANCE_PROFILE_LOW_BALANCED;
381+
} else if (g_ascii_strcasecmp (option[1], "EXTREME_POWER_SAVER") == 0) {
382+
perfProfile = SNPE_PERFORMANCE_PROFILE_EXTREME_POWER_SAVER;
383+
} else {
384+
_valid = false;
385+
g_warning ("Unknown performance profile (%s), set BALANCED as default.",
386+
options[op]);
387+
}
388+
389+
if (_valid)
390+
g_info ("Set performance profile to %s", option[1]);
358391
} else {
359392
g_warning ("Unknown option (%s).", options[op]);
360393
}
@@ -428,6 +461,10 @@ ml_snpe_configure_instance (void *backend_private, const void *prop_)
428461
}
429462
}
430463

464+
/* Set Perfornamce Profile */
465+
if (Snpe_SNPEBuilder_SetPerformanceProfile (snpebuilder_h, perfProfile) != SNPE_SUCCESS)
466+
throw std::runtime_error ("Failed to set performance profile");
467+
431468
snpe->snpe_h = Snpe_SNPEBuilder_Build (snpebuilder_h);
432469
if (!snpe->snpe_h)
433470
throw std::runtime_error ("Failed to build SNPE handle");

0 commit comments

Comments
 (0)