|
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, |
@@ -4834,6 +4835,33 @@ def setUp(self): |
4834 | 4835 | saver=False, |
4835 | 4836 | ) |
4836 | 4837 |
|
| 4838 | + def test_qnn_backend_compile_time_option_htp_performance(self): |
| 4839 | + backend_options = generate_htp_compiler_spec( |
| 4840 | + use_fp16=True, |
| 4841 | + htp_performance_mode=QnnExecuTorchHtpPerformanceMode.kHtpHighPowerSaver, |
| 4842 | + ) |
| 4843 | + TestQNN.compiler_specs = generate_qnn_executorch_compiler_spec( |
| 4844 | + soc_model=self.chipset_table[TestQNN.model], |
| 4845 | + backend_options=backend_options, |
| 4846 | + ) |
| 4847 | + module = SimpleModel() # noqa: F405 |
| 4848 | + sample_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28)) |
| 4849 | + |
| 4850 | + def output_callback(log_msg): |
| 4851 | + msg = log_msg.stdout |
| 4852 | + # Refer to HtpDevice.cpp for the following values |
| 4853 | + min_voltage = "coreVoltageCornerMin 80" |
| 4854 | + self.assertTrue(min_voltage in msg, f"Expecting '{min_voltage} ' in log") |
| 4855 | + |
| 4856 | + runtime_extra_commands = " --log_level 4" |
| 4857 | + self.lower_module_and_test_output( |
| 4858 | + module, |
| 4859 | + sample_input, |
| 4860 | + extra_cmds=runtime_extra_commands, |
| 4861 | + output_callback=partial(output_callback), |
| 4862 | + save_inference_speed=True, |
| 4863 | + ) |
| 4864 | + |
4837 | 4865 | def test_qnn_backend_dump_intermediate_outputs_topk(self): |
4838 | 4866 | TestQNN.dump_intermediate_outputs = True |
4839 | 4867 | backend_options = generate_htp_compiler_spec(use_fp16=True) |
@@ -5423,6 +5451,34 @@ def setUp(self): |
5423 | 5451 | saver=False, |
5424 | 5452 | ) |
5425 | 5453 |
|
| 5454 | + def test_qnn_backend_compile_time_option_htp_performance(self): |
| 5455 | + backend_options = generate_htp_compiler_spec( |
| 5456 | + use_fp16=False, |
| 5457 | + htp_performance_mode=QnnExecuTorchHtpPerformanceMode.kHtpHighPowerSaver, |
| 5458 | + ) |
| 5459 | + TestQNN.compiler_specs = generate_qnn_executorch_compiler_spec( |
| 5460 | + soc_model=self.chipset_table[TestQNN.model], |
| 5461 | + backend_options=backend_options, |
| 5462 | + ) |
| 5463 | + module = SimpleModel() # noqa: F405 |
| 5464 | + sample_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28)) |
| 5465 | + module = self.get_qdq_module(module, sample_input) |
| 5466 | + |
| 5467 | + def output_callback(log_msg): |
| 5468 | + msg = log_msg.stdout |
| 5469 | + # Refer to HtpDevice.cpp for the following values |
| 5470 | + min_voltage = "coreVoltageCornerMin 80" |
| 5471 | + self.assertTrue(min_voltage in msg, f"Expecting '{min_voltage} ' in log") |
| 5472 | + |
| 5473 | + runtime_extra_commands = " --log_level 4" |
| 5474 | + self.lower_module_and_test_output( |
| 5475 | + module, |
| 5476 | + sample_input, |
| 5477 | + extra_cmds=runtime_extra_commands, |
| 5478 | + output_callback=partial(output_callback), |
| 5479 | + save_inference_speed=True, |
| 5480 | + ) |
| 5481 | + |
5426 | 5482 | def test_qnn_backend_dump_intermediate_outputs_simple_model(self): |
5427 | 5483 | TestQNN.dump_intermediate_outputs = True |
5428 | 5484 | backend_options = generate_htp_compiler_spec(use_fp16=False) |
|
0 commit comments