Skip to content

Commit 309c6b1

Browse files
David Linfacebook-github-bot
authored andcommitted
make extract_delegate_segments=True by default
Summary: updated all existing callsites to use the previous default value of False Reviewed By: JacobSzwejbka, zonglinpengmeta Differential Revision: D56712292
1 parent f0f4db8 commit 309c6b1

11 files changed

Lines changed: 45 additions & 20 deletions

File tree

backends/apple/mps/test/test_mps_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ def lower_module_and_test_output(
240240
)
241241

242242
executorch_program = delegated_program.to_executorch(
243-
config=ExecutorchBackendConfig(extract_constant_segment=False)
243+
config=ExecutorchBackendConfig(
244+
extract_delegate_segments=False, extract_constant_segment=False
245+
)
244246
)
245247
else:
246248
delegated_program = to_backend(
@@ -255,7 +257,9 @@ def lower_module_and_test_output(
255257
)
256258
.to_edge(exir.EdgeCompileConfig(_check_ir_validity=False))
257259
.to_executorch(
258-
config=ExecutorchBackendConfig(extract_constant_segment=False)
260+
config=ExecutorchBackendConfig(
261+
extract_delegate_segments=False, extract_constant_segment=False
262+
)
259263
)
260264
)
261265

backends/arm/test/arm_tosa_reference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def tosa_run_test(op, profile=TosaProfile.MI): # noqa: C901
201201

202202
model_edge = model_edge.to_backend(ArmPartitioner(compile_spec))
203203
exec_prog = model_edge.to_executorch(
204-
config=ExecutorchBackendConfig(extract_constant_segment=False)
204+
config=ExecutorchBackendConfig(
205+
extract_delegate_segments=False, extract_constant_segment=False
206+
)
205207
)
206208

207209
# Save ground truth results to file

backends/qualcomm/tests/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def lower_module_and_test_output(
187187
)
188188
exec_prog = delegated_program.to_executorch(
189189
exir.ExecutorchBackendConfig(
190+
extract_delegate_segments=False,
190191
# For shared buffer, user must pass the memory address
191192
# which is allocated by RPC memory to executor runner.
192193
# Therefore, won't want to pre-allocate
@@ -195,7 +196,7 @@ def lower_module_and_test_output(
195196
memory_planning_algo="greedy",
196197
alloc_graph_input=not self.shared_buffer,
197198
alloc_graph_output=not self.shared_buffer,
198-
)
199+
),
199200
)
200201
)
201202

examples/apple/mps/scripts/mps_example.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ def get_model_config(args):
182182
logging.info(f"Lowered graph:\n{edge.exported_program().graph}")
183183

184184
executorch_program = edge.to_executorch(
185-
config=ExecutorchBackendConfig(extract_constant_segment=False)
185+
config=ExecutorchBackendConfig(
186+
extract_delegate_segments=False, extract_constant_segment=False
187+
)
186188
)
187189
else:
188190
lowered_module = to_backend(
@@ -192,7 +194,11 @@ def get_model_config(args):
192194
lowered_module,
193195
example_inputs,
194196
edge_compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
195-
).to_executorch(config=ExecutorchBackendConfig(extract_constant_segment=False))
197+
).to_executorch(
198+
config=ExecutorchBackendConfig(
199+
extract_delegate_segments=False, extract_constant_segment=False
200+
)
201+
)
196202

197203
model_name = f"{args.model_name}_mps"
198204

examples/arm/aot_arm_compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ def forward(self, x):
193193
logging.debug(f"Lowered graph:\n{edge.exported_program().graph}")
194194

195195
exec_prog = edge.to_executorch(
196-
config=ExecutorchBackendConfig(extract_constant_segment=False)
196+
config=ExecutorchBackendConfig(
197+
extract_delegate_segments=False, extract_constant_segment=False
198+
)
197199
)
198200

199201
model_name = f"{args.model_name}" + (

examples/qualcomm/scripts/export_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
)
9797

9898
executorch_program = delegated_program.to_executorch(
99-
config=ExecutorchBackendConfig(extract_constant_segment=False)
99+
config=ExecutorchBackendConfig(
100+
extract_delegate_segments=False, extract_constant_segment=False
101+
)
100102
)
101103

102104
if args.generate_etrecord:

examples/xnnpack/aot_compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@
102102
logging.info(f"Lowered graph:\n{edge.exported_program().graph}")
103103

104104
exec_prog = edge.to_executorch(
105-
config=ExecutorchBackendConfig(extract_constant_segment=False)
105+
config=ExecutorchBackendConfig(
106+
extract_delegate_segments=False, extract_constant_segment=False
107+
)
106108
)
107109

108110
if args.etrecord is not None:

examples/xnnpack/quantization/example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def main() -> None:
191191

192192
start = time.perf_counter()
193193
prog = edge_m.to_executorch(
194-
config=ExecutorchBackendConfig(extract_constant_segment=False)
194+
config=ExecutorchBackendConfig(
195+
extract_delegate_segments=False, extract_constant_segment=False
196+
)
195197
)
196198
save_pte_program(prog, f"{args.model_name}_quantized")
197199
end = time.perf_counter()

exir/capture/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ExecutorchBackendConfig:
5555
# Whether to move delegate data blobs from the Program into separate
5656
# segments, rather than encoding those blobs in the flatbuffer data.
5757
# This makes it possible to free those blobs at runtime.
58-
extract_delegate_segments: bool = False
58+
extract_delegate_segments: bool = True
5959

6060
# Whether to extract constants from the Program into separate segments,
6161
# rather than encoding those constants in the flatbuffer data.

exir/program/test/test_program.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,15 @@ def test_edge_to_backend_replaces_subgraph(self):
293293
# two delegate blobs for forward and foo
294294
self.assertEqual(
295295
len(
296-
delegate_manager.to_executorch(
297-
ExecutorchBackendConfig(extract_delegate_segments=True)
298-
)
296+
delegate_manager.to_executorch(ExecutorchBackendConfig())
299297
._emitter_output.program.execution_plan[0]
300298
.delegates
301299
),
302300
1,
303301
)
304302
self.assertEqual(
305303
len(
306-
delegate_manager.to_executorch(
307-
ExecutorchBackendConfig(extract_delegate_segments=True)
308-
)
304+
delegate_manager.to_executorch(ExecutorchBackendConfig())
309305
._emitter_output.program.execution_plan[1]
310306
.delegates
311307
),
@@ -349,15 +345,23 @@ def test_edge_to_backend_selective(self):
349345
# one delegate blob for forward
350346
self.assertEqual(
351347
len(
352-
delegate_manager.to_executorch(ExecutorchBackendConfig())
348+
delegate_manager.to_executorch(
349+
ExecutorchBackendConfig(
350+
extract_delegate_segments=False,
351+
)
352+
)
353353
._emitter_output.program.execution_plan[0] # foo
354354
.delegates
355355
),
356356
0,
357357
)
358358
self.assertEqual(
359359
len(
360-
delegate_manager.to_executorch(ExecutorchBackendConfig())
360+
delegate_manager.to_executorch(
361+
ExecutorchBackendConfig(
362+
extract_delegate_segments=False,
363+
)
364+
)
361365
._emitter_output.program.execution_plan[1] # forward
362366
.delegates
363367
),

0 commit comments

Comments
 (0)