@@ -3384,6 +3384,38 @@ def test_qnn_backend_rewrite_prepared_observer(self):
33843384 quantized_module = convert_pt2e (prepared )
33853385 self .lower_module_and_test_output (quantized_module , sample_input )
33863386
3387+ def test_qnn_backend_saver_backend (self ):
3388+ backend_options = generate_htp_compiler_spec (use_fp16 = False )
3389+ TestQNN .compiler_specs = generate_qnn_executorch_compiler_spec (
3390+ soc_model = self .chipset_table [TestQNN .model ],
3391+ backend_options = backend_options ,
3392+ saver = True ,
3393+ )
3394+ module = Relu () # noqa: F405
3395+ sample_input = (torch .randn ([2 , 5 , 1 , 3 ]),)
3396+ module = self .get_qdq_module (module , sample_input )
3397+
3398+ from executorch .backends .qualcomm .serialization .qc_schema_serialize import (
3399+ flatbuffer_to_option ,
3400+ option_to_flatbuffer ,
3401+ )
3402+
3403+ with tempfile .TemporaryDirectory () as tmp_dir :
3404+ option = flatbuffer_to_option (TestQNN .compiler_specs [0 ].value )
3405+ option .saver_output_dir = f"{ tmp_dir } /saver_output"
3406+ TestQNN .compiler_specs [0 ].value = option_to_flatbuffer (option )
3407+
3408+ with self .assertRaises (SystemExit ):
3409+ self .lower_module_and_test_output (module , sample_input )
3410+ self .assertTrue (
3411+ os .path .isfile (f"{ tmp_dir } /saver_output/params.bin" ),
3412+ "failed to find params.bin" ,
3413+ )
3414+ self .assertTrue (
3415+ os .path .isfile (f"{ tmp_dir } /saver_output/saver_output.c" ),
3416+ "failed to find saver_output.c" ,
3417+ )
3418+
33873419 def test_qnn_backend_skip_node_id_partitioner (self ):
33883420 module = SimpleModel () # noqa: F405
33893421 sample_input = (torch .ones (1 , 32 , 28 , 28 ), torch .ones (1 , 32 , 28 , 28 ))
0 commit comments