|
29 | 29 | from executorch.backends.qualcomm.debugger.utils import generate_optrace |
30 | 30 | from executorch.backends.qualcomm.serialization.qc_schema import ( |
31 | 31 | QnnExecuTorchBackendType, |
| 32 | + QnnExecuTorchHtpPerformanceMode, |
32 | 33 | ) |
33 | 34 | from executorch.backends.qualcomm.tests.utils import ( |
34 | 35 | convert_pt2e, |
@@ -4847,6 +4848,33 @@ def setUp(self): |
4847 | 4848 | saver=False, |
4848 | 4849 | ) |
4849 | 4850 |
|
| 4851 | + def test_qnn_backend_compile_time_option_htp_performance(self): |
| 4852 | + backend_options = generate_htp_compiler_spec( |
| 4853 | + use_fp16=True, |
| 4854 | + htp_performance_mode=QnnExecuTorchHtpPerformanceMode.kHtpHighPowerSaver, |
| 4855 | + ) |
| 4856 | + TestQNN.compiler_specs = generate_qnn_executorch_compiler_spec( |
| 4857 | + soc_model=self.chipset_table[TestQNN.model], |
| 4858 | + backend_options=backend_options, |
| 4859 | + ) |
| 4860 | + module = SimpleModel() # noqa: F405 |
| 4861 | + sample_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28)) |
| 4862 | + |
| 4863 | + def output_callback(log_msg): |
| 4864 | + msg = log_msg.stdout |
| 4865 | + # Refer to HtpDevice.cpp for the following values |
| 4866 | + min_voltage = "coreVoltageCornerMin 80" |
| 4867 | + self.assertTrue(min_voltage in msg, f"Expecting '{min_voltage} ' in log") |
| 4868 | + |
| 4869 | + runtime_extra_commands = " --log_level 4" |
| 4870 | + self.lower_module_and_test_output( |
| 4871 | + module, |
| 4872 | + sample_input, |
| 4873 | + extra_cmds=runtime_extra_commands, |
| 4874 | + output_callback=partial(output_callback), |
| 4875 | + save_inference_speed=True, |
| 4876 | + ) |
| 4877 | + |
4850 | 4878 | def test_qnn_backend_dump_intermediate_outputs_topk(self): |
4851 | 4879 | TestQNN.dump_intermediate_outputs = True |
4852 | 4880 | backend_options = generate_htp_compiler_spec(use_fp16=True) |
@@ -5436,6 +5464,34 @@ def setUp(self): |
5436 | 5464 | saver=False, |
5437 | 5465 | ) |
5438 | 5466 |
|
| 5467 | + def test_qnn_backend_compile_time_option_htp_performance(self): |
| 5468 | + backend_options = generate_htp_compiler_spec( |
| 5469 | + use_fp16=False, |
| 5470 | + htp_performance_mode=QnnExecuTorchHtpPerformanceMode.kHtpHighPowerSaver, |
| 5471 | + ) |
| 5472 | + TestQNN.compiler_specs = generate_qnn_executorch_compiler_spec( |
| 5473 | + soc_model=self.chipset_table[TestQNN.model], |
| 5474 | + backend_options=backend_options, |
| 5475 | + ) |
| 5476 | + module = SimpleModel() # noqa: F405 |
| 5477 | + sample_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28)) |
| 5478 | + module = self.get_qdq_module(module, sample_input) |
| 5479 | + |
| 5480 | + def output_callback(log_msg): |
| 5481 | + msg = log_msg.stdout |
| 5482 | + # Refer to HtpDevice.cpp for the following values |
| 5483 | + min_voltage = "coreVoltageCornerMin 80" |
| 5484 | + self.assertTrue(min_voltage in msg, f"Expecting '{min_voltage} ' in log") |
| 5485 | + |
| 5486 | + runtime_extra_commands = " --log_level 4" |
| 5487 | + self.lower_module_and_test_output( |
| 5488 | + module, |
| 5489 | + sample_input, |
| 5490 | + extra_cmds=runtime_extra_commands, |
| 5491 | + output_callback=partial(output_callback), |
| 5492 | + save_inference_speed=True, |
| 5493 | + ) |
| 5494 | + |
5439 | 5495 | def test_qnn_backend_dump_intermediate_outputs_simple_model(self): |
5440 | 5496 | TestQNN.dump_intermediate_outputs = True |
5441 | 5497 | backend_options = generate_htp_compiler_spec(use_fp16=False) |
|
0 commit comments