|
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, |
@@ -4790,6 +4791,33 @@ def setUp(self): |
4790 | 4791 | saver=False, |
4791 | 4792 | ) |
4792 | 4793 |
|
| 4794 | + def test_qnn_backend_compile_time_option_htp_performance(self): |
| 4795 | + backend_options = generate_htp_compiler_spec( |
| 4796 | + use_fp16=True, |
| 4797 | + htp_performance_mode=QnnExecuTorchHtpPerformanceMode.kHtpHighPowerSaver, |
| 4798 | + ) |
| 4799 | + TestQNN.compiler_specs = generate_qnn_executorch_compiler_spec( |
| 4800 | + soc_model=self.chipset_table[TestQNN.model], |
| 4801 | + backend_options=backend_options, |
| 4802 | + ) |
| 4803 | + module = SimpleModel() # noqa: F405 |
| 4804 | + sample_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28)) |
| 4805 | + |
| 4806 | + def output_callback(log_msg): |
| 4807 | + msg = log_msg.stdout |
| 4808 | + # Refer to HtpDevice.cpp for the following values |
| 4809 | + min_voltage = "coreVoltageCornerMin 80" |
| 4810 | + self.assertTrue(min_voltage in msg, f"Expecting '{min_voltage} ' in log") |
| 4811 | + |
| 4812 | + runtime_extra_commands = " --log_level 4" |
| 4813 | + self.lower_module_and_test_output( |
| 4814 | + module, |
| 4815 | + sample_input, |
| 4816 | + extra_cmds=runtime_extra_commands, |
| 4817 | + output_callback=partial(output_callback), |
| 4818 | + save_inference_speed=True, |
| 4819 | + ) |
| 4820 | + |
4793 | 4821 | def test_qnn_backend_dump_intermediate_outputs_topk(self): |
4794 | 4822 | TestQNN.dump_intermediate_outputs = True |
4795 | 4823 | backend_options = generate_htp_compiler_spec(use_fp16=True) |
@@ -5379,6 +5407,34 @@ def setUp(self): |
5379 | 5407 | saver=False, |
5380 | 5408 | ) |
5381 | 5409 |
|
| 5410 | + def test_qnn_backend_compile_time_option_htp_performance(self): |
| 5411 | + backend_options = generate_htp_compiler_spec( |
| 5412 | + use_fp16=False, |
| 5413 | + htp_performance_mode=QnnExecuTorchHtpPerformanceMode.kHtpHighPowerSaver, |
| 5414 | + ) |
| 5415 | + TestQNN.compiler_specs = generate_qnn_executorch_compiler_spec( |
| 5416 | + soc_model=self.chipset_table[TestQNN.model], |
| 5417 | + backend_options=backend_options, |
| 5418 | + ) |
| 5419 | + module = SimpleModel() # noqa: F405 |
| 5420 | + sample_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28)) |
| 5421 | + module = self.get_qdq_module(module, sample_input) |
| 5422 | + |
| 5423 | + def output_callback(log_msg): |
| 5424 | + msg = log_msg.stdout |
| 5425 | + # Refer to HtpDevice.cpp for the following values |
| 5426 | + min_voltage = "coreVoltageCornerMin 80" |
| 5427 | + self.assertTrue(min_voltage in msg, f"Expecting '{min_voltage} ' in log") |
| 5428 | + |
| 5429 | + runtime_extra_commands = " --log_level 4" |
| 5430 | + self.lower_module_and_test_output( |
| 5431 | + module, |
| 5432 | + sample_input, |
| 5433 | + extra_cmds=runtime_extra_commands, |
| 5434 | + output_callback=partial(output_callback), |
| 5435 | + save_inference_speed=True, |
| 5436 | + ) |
| 5437 | + |
5382 | 5438 | def test_qnn_backend_dump_intermediate_outputs_simple_model(self): |
5383 | 5439 | TestQNN.dump_intermediate_outputs = True |
5384 | 5440 | backend_options = generate_htp_compiler_spec(use_fp16=False) |
|
0 commit comments