Skip to content

Commit 76aced5

Browse files
qti-hungjuiwjeffkilpatrick
authored andcommitted
Revert "[AISW-141364] Implement Efficient Mode API (microsoft#137)"
This reverts commit 11f0f4c.
1 parent d80687b commit 76aced5

File tree

5 files changed

+2
-126
lines changed

5 files changed

+2
-126
lines changed

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -710,23 +710,6 @@ Status SetQnnContextConfig(ContextPriority context_priority, QnnContext_Config_t
710710
return Status::OK();
711711
}
712712

713-
Status QnnBackendManager::SetContextPriority(ContextPriority context_priority) {
714-
QnnContext_Config_t context_priority_config = QNN_CONTEXT_CONFIG_INIT;
715-
ORT_RETURN_IF_ERROR(SetQnnContextConfig(context_priority, context_priority_config));
716-
717-
QnnContext_Config_t* configs[] = {&context_priority_config, nullptr};
718-
for (const auto& context_handle : contexts_) {
719-
auto result = qnn_interface_.contextSetConfig(context_handle, (const QnnContext_Config_t**)configs);
720-
ORT_RETURN_IF(QNN_CONTEXT_NO_ERROR != result, "Failed to set context priority for context handle: ", context_handle);
721-
}
722-
723-
return Status::OK();
724-
}
725-
726-
Status QnnBackendManager::ResetContextPriority() {
727-
return SetContextPriority(context_priority_);
728-
}
729-
730713
// callback required to add context handles to class list
731714
// when using contextCreateFromBinaryListAsync()
732715
void ContextCreateAsyncCallback(Qnn_ContextHandle_t context,

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,6 @@ class QnnBackendManager : public std::enable_shared_from_this<QnnBackendManager>
220220
// For each node name, a mapping to the context handle will be created
221221
void ProcessContextFromBinListAsync(Qnn_ContextHandle_t handle, void* notifyParam);
222222

223-
// Sets the context priority to the given value, if valid
224-
Status SetContextPriority(ContextPriority context_priority);
225-
// Resets the context priority to the session default as defined by context_priority_
226-
Status ResetContextPriority();
227-
228223
private:
229224
Status LoadBackend();
230225

onnxruntime/core/providers/qnn/qnn_execution_provider.cc

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,38 +1554,4 @@ OrtDevice QNNExecutionProvider::GetOrtDeviceByMemType(OrtMemType /* em_type */)
15541554
return default_device_;
15551555
}
15561556

1557-
Status QNNExecutionProvider::SetEpDynamicOptions(gsl::span<const char* const> keys,
1558-
gsl::span<const char* const> values) {
1559-
if (keys.size() != values.size()) {
1560-
LOGS_DEFAULT(ERROR) << "SetEpDynamicOptions: number of keys (" << keys.size()
1561-
<< ") does not equal number of values (" << values.size() << ").";
1562-
}
1563-
auto key_it = keys.begin();
1564-
auto value_it = values.begin();
1565-
1566-
while (key_it != keys.end() && value_it != values.end()) {
1567-
std::string key(*key_it);
1568-
std::string value(*value_it);
1569-
1570-
if (key == kOrtEpDynamicOptionsWorkloadType) {
1571-
if (value == "Default") {
1572-
ORT_RETURN_IF_ERROR(qnn_backend_manager_->ResetContextPriority());
1573-
} else if (value == "Efficient") {
1574-
ORT_RETURN_IF_ERROR(qnn_backend_manager_->SetContextPriority(qnn::ContextPriority::LOW));
1575-
} else {
1576-
LOGS_DEFAULT(ERROR) << "Invalid EP Workload Type: " << value;
1577-
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Invalid EP Workload Type.");
1578-
}
1579-
} else {
1580-
LOGS_DEFAULT(ERROR) << "EP Dynamic Option \"" << key << "\" is not currently supported.";
1581-
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Unsupported EP Dynamic Option");
1582-
}
1583-
1584-
key_it++;
1585-
value_it++;
1586-
}
1587-
1588-
return Status::OK();
1589-
}
1590-
15911557
} // namespace onnxruntime

onnxruntime/core/providers/qnn/qnn_execution_provider.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ class QNNExecutionProvider : public IExecutionProvider {
5757

5858
OrtDevice GetOrtDeviceByMemType(OrtMemType mem_type) const override;
5959

60-
Status SetEpDynamicOptions(gsl::span<const char* const> keys,
61-
gsl::span<const char* const> value) override;
62-
6360
private:
6461
std::unordered_set<const Node*> GetSupportedNodes(const GraphViewer& graph_viewer,
6562
const std::unordered_map<const Node*, const NodeUnit*>& node_unit_map,

onnxruntime/test/providers/qnn/qnn_ep_context_test.cc

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,7 @@ static void DumpModelWithSharedCtx(ProviderOptions provider_options,
16491649
Ort::Session session2(*ort_env, ToPathString(onnx_model_path2).c_str(), so);
16501650
}
16511651

1652+
#if defined(__aarch64__) || defined(_M_ARM64)
16521653
static void GetModelInputNames(const std::string& model_path,
16531654
std::vector<std::string>& input_names,
16541655
std::vector<std::string>& output_names,
@@ -1668,6 +1669,7 @@ static void GetModelInputNames(const std::string& model_path,
16681669
output_names.push_back(output->Name());
16691670
}
16701671
}
1672+
#endif
16711673

16721674
// 1. Create 2 QDQ models
16731675
// 2. Initialize 2 Ort sessions which share the same QNN EP from these 2 QDQ models
@@ -1996,73 +1998,6 @@ TEST_F(QnnHTPBackendTests, LoadFromArrayWithQnnEpContextGenPathValidation) {
19961998
});
19971999
}
19982000
}
1999-
2000-
TEST_F(QnnHTPBackendTests, QnnEpDynamicOptions) {
2001-
ProviderOptions provider_options;
2002-
provider_options["backend_type"] = "htp";
2003-
provider_options["offload_graph_io_quantization"] = "0";
2004-
2005-
Ort::SessionOptions so;
2006-
so.AppendExecutionProvider("QNN", provider_options);
2007-
so.SetLogSeverityLevel(ORT_LOGGING_LEVEL_VERBOSE);
2008-
2009-
Ort::Session session(*ort_env, ORT_TSTR("testdata/qnn_ctx/qnn_multi_ctx_embed.onnx"), so);
2010-
2011-
std::vector<std::string> input_names;
2012-
std::vector<std::string> output_names;
2013-
GetModelInputNames("testdata/qnn_ctx/qnn_multi_ctx_embed.onnx", input_names, output_names,
2014-
DefaultLoggingManager().DefaultLogger());
2015-
2016-
// Run sessions
2017-
// prepare input
2018-
std::vector<int64_t> input_dim{3, 4};
2019-
std::vector<float> input_value(3 * 4, 0.0f);
2020-
Ort::MemoryInfo info("Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault);
2021-
std::vector<Ort::Value> ort_inputs;
2022-
std::vector<const char*> input_names_c;
2023-
for (size_t i = 0; i < input_names.size(); ++i) {
2024-
auto input_tensor = Ort::Value::CreateTensor(info, input_value.data(), input_value.size(),
2025-
input_dim.data(), input_dim.size());
2026-
ort_inputs.push_back(std::move(input_tensor));
2027-
input_names_c.push_back(input_names[i].c_str());
2028-
}
2029-
std::vector<const char*> output_names_c;
2030-
for (size_t i = 0; i < output_names.size(); ++i) {
2031-
output_names_c.push_back(output_names[i].c_str());
2032-
}
2033-
2034-
auto ort_output = session.Run(Ort::RunOptions{}, input_names_c.data(), ort_inputs.data(), ort_inputs.size(),
2035-
output_names_c.data(), 1);
2036-
2037-
const char* const workload_type[] = {"ep.dynamic.workload_type"};
2038-
const char* const efficient_type[] = {"Efficient"};
2039-
const char* const default_type[] = {"Default"};
2040-
2041-
// Test Efficent & Default options
2042-
session.SetEpDynamicOptions(workload_type, efficient_type, 1);
2043-
ort_output = session.Run(Ort::RunOptions{}, input_names_c.data(), ort_inputs.data(), ort_inputs.size(),
2044-
output_names_c.data(), 1);
2045-
2046-
session.SetEpDynamicOptions(workload_type, default_type, 1);
2047-
ort_output = session.Run(Ort::RunOptions{}, input_names_c.data(), ort_inputs.data(), ort_inputs.size(),
2048-
output_names_c.data(), 1);
2049-
2050-
// Test invalid EP dynamic option and invalid workload type
2051-
const char* const dne[] = {"DNE"};
2052-
try {
2053-
session.SetEpDynamicOptions(workload_type, dne, 1);
2054-
FAIL() << "Expected exception to be thrown for workload type DNE but was set successfully";
2055-
} catch (const std::exception& e) {
2056-
EXPECT_STREQ("Invalid EP Workload Type.", e.what());
2057-
}
2058-
2059-
try {
2060-
session.SetEpDynamicOptions(dne, efficient_type, 1);
2061-
FAIL() << "Expected exception to be thrown for dynamic option DNE but was set successfully";
2062-
} catch (const std::exception& e) {
2063-
EXPECT_STREQ("Unsupported EP Dynamic Option", e.what());
2064-
}
2065-
}
20662001
#endif // defined(__aarch64__) || defined(_M_ARM64) || defined(__linux__)
20672002

20682003
} // namespace test

0 commit comments

Comments
 (0)