99from executorch .backends .arm .test import common
1010from executorch .backends .arm .test .tester .arm_tester import ArmTester
1111from executorch .backends .arm .test .tester .test_pipeline import (
12+ EthosU85PipelineINT ,
13+ OpNotSupportedPipeline ,
1214 TosaPipelineFP ,
1315 TosaPipelineINT ,
16+ VgfPipeline ,
1417)
18+ from pytest import mark
1519
1620aten_op = "torch.ops.higher_order.cond"
1721exir_op = "torch.ops.higher_order.cond"
@@ -210,6 +214,15 @@ def _make_calibration_samples(
210214 return (if_example_inputs , else_example_inputs )
211215
212216
217+ def _set_branch_calibration_samples (
218+ pipeline , module : torch .nn .Module , example_inputs : tuple
219+ ) -> None :
220+ calibration_samples = _make_calibration_samples (module , example_inputs )
221+ quant_stage_pos = pipeline .find_pos ("quantize" )
222+ quant_stage = pipeline ._stages [quant_stage_pos ].args [0 ]
223+ quant_stage .calibration_samples = calibration_samples
224+
225+
213226@common .parametrize (
214227 "case" ,
215228 test_cases ,
@@ -247,10 +260,7 @@ def test_cond_tosa_INT(case: Callable[[], tuple[torch.nn.Module, tuple]]):
247260 pipeline = TosaPipelineINT [tuple ](
248261 module , example_inputs , aten_op , tosa_extensions = ["cf" ]
249262 )
250- calibration_samples = _make_calibration_samples (module , example_inputs )
251- quant_stage_pos = pipeline .find_pos ("quantize" )
252- quant_stage = pipeline ._stages [quant_stage_pos ].args [0 ]
253- quant_stage .calibration_samples = calibration_samples
263+ _set_branch_calibration_samples (pipeline , module , example_inputs )
254264
255265 # Make sure no cond ops are left after partitioning.
256266 pipeline .add_stage_after (
@@ -260,3 +270,69 @@ def test_cond_tosa_INT(case: Callable[[], tuple[torch.nn.Module, tuple]]):
260270 ["torch.ops.higher_order.cond" ],
261271 )
262272 pipeline .run ()
273+
274+
275+ @common .parametrize (
276+ "case" ,
277+ test_cases ,
278+ )
279+ def test_cond_u55_INT (case : Callable [[], tuple [torch .nn .Module , tuple ]]):
280+ module , example_inputs = case ()
281+ pipeline = OpNotSupportedPipeline [tuple ](module , example_inputs , {aten_op : 1 })
282+ pipeline .pop_stage ("check_count.exir" )
283+ pipeline .run ()
284+
285+
286+ @common .parametrize (
287+ "case" ,
288+ test_cases ,
289+ xfails = {
290+ "one_arg_and_scalar_one_output" : "Incorrect quantization on the scalar." ,
291+ "nested_one_arg_one_output" : "Node submodule_0 target submodule_0 references nonexistent attribute submodule_0" ,
292+ },
293+ skips = {
294+ "one_arg_one_output" : "Segfault when transpose goes into cond. MLBEDSW-11416." ,
295+ "one_arg_const_one_output" : "Segfault when transpose goes into cond. MLBEDSW-11416." ,
296+ "multiple_one_arg_one_output" : "Segfault when transpose goes into cond. MLBEDSW-11416." ,
297+ },
298+ )
299+ @common .XfailIfNoCorstone320 .with_args (raises = None )
300+ def test_cond_u85_INT (case : Callable [[], tuple [torch .nn .Module , tuple ]]):
301+ module , example_inputs = case ()
302+ pipeline = EthosU85PipelineINT [tuple ](module , example_inputs , aten_op , exir_op )
303+ _set_branch_calibration_samples (pipeline , module , example_inputs )
304+ pipeline .run ()
305+
306+
307+ @mark .skip ("Cond not supported in model_converter." )
308+ @common .parametrize (
309+ "case" ,
310+ test_cases ,
311+ )
312+ @common .SkipIfNoModelConverter
313+ def test_cond_vgf_FP (case : Callable [[], tuple [torch .nn .Module , tuple ]]):
314+ module , example_inputs = case ()
315+ VgfPipeline [tuple ](
316+ module ,
317+ example_inputs ,
318+ aten_op ,
319+ exir_op ,
320+ ).run ()
321+
322+
323+ @mark .skip ("Cond not supported in model_converter." )
324+ @common .parametrize (
325+ "case" ,
326+ test_cases ,
327+ )
328+ @common .SkipIfNoModelConverter
329+ def test_cond_vgf_INT (case : Callable [[], tuple [torch .nn .Module , tuple ]]):
330+ module , example_inputs = case ()
331+ pipeline = VgfPipeline [tuple ](
332+ module ,
333+ example_inputs ,
334+ aten_op ,
335+ exir_op ,
336+ )
337+ _set_branch_calibration_samples (pipeline , module , example_inputs )
338+ pipeline .run ()
0 commit comments