File tree Expand file tree Collapse file tree 5 files changed +40
-8
lines changed Expand file tree Collapse file tree 5 files changed +40
-8
lines changed Original file line number Diff line number Diff line change 1414class ToEdgeTransformAndLower (Stage ):
1515 def __init__ (
1616 self ,
17- default_partitioner_cls : Type ,
17+ default_partitioner_cls : Type | None = None ,
1818 partitioners : Optional [List [Partitioner ]] = None ,
1919 edge_compile_config : Optional [EdgeCompileConfig ] = None ,
2020 ):
21- self .partitioners = partitioners or [default_partitioner_cls ()]
21+ self .partitioners = (
22+ partitioners or [default_partitioner_cls ()]
23+ if default_partitioner_cls is not None
24+ else []
25+ )
2226 self .edge_compile_conf = edge_compile_config or EdgeCompileConfig ()
2327 self .edge_dialect_program = None
2428
Original file line number Diff line number Diff line change @@ -34,12 +34,12 @@ def __init__(
3434 self ,
3535 module : torch .nn .Module ,
3636 example_inputs : Tuple [torch .Tensor ],
37- stage_classes : Dict [StageType , Callable ],
37+ stage_classes : Dict [StageType , Callable ] | None = None ,
3838 dynamic_shapes : Optional [Tuple [Any ]] = None ,
3939 ):
4040 module .eval ()
4141
42- self .stage_classes = stage_classes
42+ self .stage_classes = stage_classes or Tester . default_stage_classes ()
4343 self .original_module = module
4444 self .example_inputs = example_inputs
4545 self .dynamic_shapes = dynamic_shapes
Original file line number Diff line number Diff line change 11import logging
22
3- from dataclasses import dataclass , field
3+ from dataclasses import dataclass
44from typing import Callable
55
66from executorch .backends .test .harness import Tester
@@ -26,16 +26,25 @@ class TestFlow:
2626 tester_factory : Callable [..., Tester ]
2727 """ A factory function that returns a Tester instance for this lowering flow. """
2828
29- quantize : bool = field ( default = False )
29+ quantize : bool = False
3030 """ Whether to tester should run the quantize stage on the model. """
3131
3232 quantize_stage_factory : Callable [..., Quantize ] | None = None
3333 """ A factory function which instantiates a Quantize stage. Can be None to use the tester's default. """
3434
35+ is_delegated : bool = True
36+ """ Indicates whether the flow is expected to generate CALL_DELEGATE nodes. """
37+
3538
3639def all_flows () -> dict [str , TestFlow ]:
3740 flows = []
3841
42+ from executorch .backends .test .suite .flows .portable import PORTABLE_TEST_FLOW
43+
44+ flows += [
45+ PORTABLE_TEST_FLOW ,
46+ ]
47+
3948 try :
4049 from executorch .backends .test .suite .flows .xnnpack import (
4150 XNNPACK_STATIC_INT8_PER_CHANNEL_TEST_FLOW ,
Original file line number Diff line number Diff line change 1+ import logging
2+
3+ from executorch .backends .test .harness import Tester
4+ from executorch .backends .test .suite .flow import TestFlow
5+
6+ logger = logging .getLogger (__name__ )
7+ logger .setLevel (logging .INFO )
8+
9+
10+ def _create_portable_flow () -> TestFlow :
11+ return TestFlow (
12+ "portable" ,
13+ backend = "portable" ,
14+ tester_factory = Tester ,
15+ is_delegated = False ,
16+ )
17+
18+
19+ PORTABLE_TEST_FLOW = _create_portable_flow ()
Original file line number Diff line number Diff line change @@ -125,8 +125,8 @@ def build_result(
125125 if n .op == "call_function"
126126 )
127127
128- # Only run the runtime portion if something was delegated.
129- if is_delegated :
128+ # Only run the runtime portion if something was delegated (or the flow doesn't delegate) .
129+ if is_delegated or not flow . is_delegated :
130130 try :
131131 tester .to_executorch ().serialize ()
132132 extra_stats ["pte_size_bytes" ] = len (tester .get_artifact ())
You can’t perform that action at this time.
0 commit comments