File tree Expand file tree Collapse file tree 5 files changed +39
-7
lines changed Expand file tree Collapse file tree 5 files changed +39
-7
lines changed Original file line number Diff line number Diff line change 15
15
class ToEdgeTransformAndLower (Stage ):
16
16
def __init__ (
17
17
self ,
18
- default_partitioner_cls : Type ,
18
+ default_partitioner_cls : Type | None = None ,
19
19
partitioners : Optional [List [Partitioner ]] = None ,
20
20
edge_compile_config : Optional [EdgeCompileConfig ] = None ,
21
21
):
22
- self .partitioners = partitioners or [default_partitioner_cls ()]
22
+ self .partitioners = (
23
+ partitioners or [default_partitioner_cls ()]
24
+ if default_partitioner_cls is not None
25
+ else []
26
+ )
23
27
self .edge_compile_conf = edge_compile_config or EdgeCompileConfig ()
24
28
self .edge_dialect_program = None
25
29
Original file line number Diff line number Diff line change @@ -34,12 +34,12 @@ def __init__(
34
34
self ,
35
35
module : torch .nn .Module ,
36
36
example_inputs : Tuple [torch .Tensor ],
37
- stage_classes : Dict [StageType , Callable ],
37
+ stage_classes : Dict [StageType , Callable ] | None = None ,
38
38
dynamic_shapes : Optional [Tuple [Any ]] = None ,
39
39
):
40
40
module .eval ()
41
41
42
- self .stage_classes = stage_classes
42
+ self .stage_classes = stage_classes or Tester . default_stage_classes ()
43
43
self .original_module = module
44
44
self .example_inputs = example_inputs
45
45
self .dynamic_shapes = dynamic_shapes
Original file line number Diff line number Diff line change @@ -26,16 +26,25 @@ class TestFlow:
26
26
tester_factory : Callable [..., Tester ]
27
27
""" A factory function that returns a Tester instance for this lowering flow. """
28
28
29
- quantize : bool = field ( default = False )
29
+ quantize : bool = False
30
30
""" Whether to tester should run the quantize stage on the model. """
31
31
32
32
quantize_stage_factory : Callable [..., Quantize ] | None = None
33
33
""" A factory function which instantiates a Quantize stage. Can be None to use the tester's default. """
34
34
35
+ is_delegated : bool = True
36
+ """ Indicates whether the flow is expected to generate CALL_DELEGATE nodes. """
37
+
35
38
36
39
def all_flows () -> dict [str , TestFlow ]:
37
40
flows = []
38
41
42
+ from executorch .backends .test .suite .flows .portable import PORTABLE_TEST_FLOW
43
+
44
+ flows += [
45
+ PORTABLE_TEST_FLOW ,
46
+ ]
47
+
39
48
try :
40
49
from executorch .backends .test .suite .flows .xnnpack import (
41
50
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(
125
125
if n .op == "call_function"
126
126
)
127
127
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 :
130
130
try :
131
131
tester .to_executorch ().serialize ()
132
132
extra_stats ["pte_size_bytes" ] = len (tester .get_artifact ())
You can’t perform that action at this time.
0 commit comments