Skip to content

Commit c813155

Browse files
committed
fixed issues from reviews
1 parent ec6d260 commit c813155

5 files changed

Lines changed: 24 additions & 6 deletions

File tree

backends/qualcomm/runtime/QnnExecuTorchBackend.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ executorch::runtime::Error QnnExecuTorchBackend::get_option(
275275
executorch::runtime::BackendOptionContext& context,
276276
executorch::runtime::Span<executorch::runtime::BackendOption>&
277277
backend_options) {
278+
std::lock_guard<std::mutex> guard(runtime_option_mutex_);
278279
size_t matches = backend_options.size();
279280
for (size_t i = 0; i < backend_options.size(); ++i) {
280281
// Set the value to what was stored by set_option

backends/qualcomm/runtime/backends/QnnContextCommon.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ class QnnContext {
3939
device_(device),
4040
cache_(cache),
4141
qnn_dlc_manager_(qnn_dlc_manager),
42-
profile_level_(profile_level),
4342
is_htp_backend_(
4443
implementation->GetQnnInterface().GetBackendId() ==
4544
QNN_BACKEND_ID_HTP),
4645
need_to_profile_(
4746
profile_level != QnnExecuTorchProfileLevel::kProfileOff) {
4847
qnn_profiler_ =
49-
std::make_unique<QnnProfile>(implementation_, backend_, profile_level_);
48+
std::make_unique<QnnProfile>(implementation_, backend_, profile_level);
5049
}
5150

5251
virtual ~QnnContext();
@@ -95,7 +94,6 @@ class QnnContext {
9594
QnnContextCustomProtocol qnn_context_custom_protocol_;
9695
QnnDlcManager* qnn_dlc_manager_;
9796

98-
QnnExecuTorchProfileLevel profile_level_;
9997
std::unique_ptr<QnnProfile> qnn_profiler_;
10098
bool is_htp_backend_;
10199
bool need_to_profile_;

backends/qualcomm/runtime/backends/QnnProfiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Qnn_ErrorHandle_t QnnProfile::ProfileData(
195195
}
196196

197197
Qnn_ErrorHandle_t QnnProfile::ProfileDataToFile(
198-
const std::string profile_filename) {
198+
const std::string& profile_filename) {
199199
if (handle_ == nullptr) {
200200
QNN_EXECUTORCH_LOG_WARN(
201201
"Profile handle is null, skipping ProfileDataToFile");

backends/qualcomm/runtime/backends/QnnProfiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class QnnProfile {
2727
const QnnExecuTorchProfileLevel& profile_level);
2828
~QnnProfile();
2929
Qnn_ErrorHandle_t ProfileData(executorch::runtime::EventTracer* event_tracer);
30-
Qnn_ErrorHandle_t ProfileDataToFile(const std::string profile_filename);
30+
Qnn_ErrorHandle_t ProfileDataToFile(const std::string& profile_filename);
3131

3232
Qnn_ProfileHandle_t GetHandle() {
3333
return handle_;

examples/qualcomm/executor_runner/qnn_executor_runner.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ DEFINE_int32(
142142
"This is a runtime option and will override the profile level set during AOT. "
143143
"Refer to QnnExecuTorchProfileLevel under qc_compiler_spec.fbs for more info.");
144144

145+
DEFINE_string(
146+
heap_profiling_path,
147+
"",
148+
"Output path for QNN heap-profiling dump. "
149+
"Empty disables heap profiling. "
150+
"This is a runtime option and will override the path set during AOT.");
151+
145152
using executorch::aten::Tensor;
146153
using executorch::aten::TensorImpl;
147154
using executorch::etdump::ETDumpGen;
@@ -212,7 +219,7 @@ int main(int argc, char** argv) {
212219
}
213220

214221
// Set runtime options
215-
executorch::runtime::BackendOptions<8> backend_options;
222+
executorch::runtime::BackendOptions<9> backend_options;
216223
if (!gflags::GetCommandLineFlagInfoOrDie("log_level").is_default) {
217224
ET_LOG(Info, "Setting runtime log level: %d", FLAGS_log_level);
218225
ET_CHECK_MSG(
@@ -290,6 +297,18 @@ int main(int argc, char** argv) {
290297
"Failed to set backend options: %s",
291298
QNN_RUNTIME_LPAI_CORE_SELECTION);
292299
}
300+
if (!gflags::GetCommandLineFlagInfoOrDie("heap_profiling_path").is_default) {
301+
ET_LOG(
302+
Info,
303+
"Setting runtime heap_profiling_path: %s",
304+
FLAGS_heap_profiling_path.c_str());
305+
ET_CHECK_MSG(
306+
backend_options.set_option(
307+
QNN_RUNTIME_HEAP_PROFILING_PATH,
308+
FLAGS_heap_profiling_path.c_str()) == Error::Ok,
309+
"Failed to set backend options: %s",
310+
QNN_RUNTIME_HEAP_PROFILING_PATH);
311+
}
293312
ET_CHECK_MSG(
294313
set_option(QNN_BACKEND, backend_options.view()) == Error::Ok,
295314
"Failed to set runtime options.");

0 commit comments

Comments
 (0)