Remove usages of extract_constant_segment=False

Differential Revision: D61945429

Pull Request resolved: https://github.com/pytorch/executorch/pull/5074
diff --git a/backends/apple/mps/test/test_mps_utils.py b/backends/apple/mps/test/test_mps_utils.py
index 199a7fe..6f7d00d 100644
--- a/backends/apple/mps/test/test_mps_utils.py
+++ b/backends/apple/mps/test/test_mps_utils.py
@@ -239,9 +239,7 @@
             )
 
             executorch_program = delegated_program.to_executorch(
-                config=ExecutorchBackendConfig(
-                    extract_delegate_segments=False, extract_constant_segment=False
-                )
+                config=ExecutorchBackendConfig(extract_delegate_segments=False)
             )
         else:
             delegated_program = to_backend(
@@ -258,9 +256,7 @@
                     _skip_dim_order=True,  # TODO(T182928844): Delegate dim order op to backend.
                 ),
             ).to_executorch(
-                config=ExecutorchBackendConfig(
-                    extract_delegate_segments=False, extract_constant_segment=False
-                )
+                config=ExecutorchBackendConfig(extract_delegate_segments=False)
             )
 
         if bundled_program:
diff --git a/examples/apple/coreml/scripts/export.py b/examples/apple/coreml/scripts/export.py
index 5a8c9b2..e906c07 100644
--- a/examples/apple/coreml/scripts/export.py
+++ b/examples/apple/coreml/scripts/export.py
@@ -104,11 +104,7 @@
     lowered_module(*example_inputs)
     exec_prog = to_edge(
         export(lowered_module, example_inputs), compile_config=_EDGE_COMPILE_CONFIG
-    ).to_executorch(
-        config=exir.ExecutorchBackendConfig(
-            extract_constant_segment=False, extract_delegate_segments=True
-        )
-    )
+    ).to_executorch(config=exir.ExecutorchBackendConfig(extract_delegate_segments=True))
 
     return exec_prog
 
@@ -178,9 +174,7 @@
         )
         delegated_program_manager = edge_program_manager.to_backend(partitioner)
         exec_program = delegated_program_manager.to_executorch(
-            config=exir.ExecutorchBackendConfig(
-                extract_constant_segment=False, extract_delegate_segments=True
-            )
+            config=exir.ExecutorchBackendConfig(extract_delegate_segments=True)
         )
     else:
         lowered_module, edge_copy = lower_module_to_coreml(
diff --git a/examples/apple/coreml/scripts/inspector_utils.py b/examples/apple/coreml/scripts/inspector_utils.py
index c5674ec..9d7420a 100644
--- a/examples/apple/coreml/scripts/inspector_utils.py
+++ b/examples/apple/coreml/scripts/inspector_utils.py
@@ -79,7 +79,6 @@
 )
 
 _EDGE_BACKEND_CONFIG = exir.ExecutorchBackendConfig(
-    extract_constant_segment=False,
     extract_delegate_segments=True,
 )
 
diff --git a/examples/apple/mps/scripts/mps_example.py b/examples/apple/mps/scripts/mps_example.py
index 636444e..d6416e0 100644
--- a/examples/apple/mps/scripts/mps_example.py
+++ b/examples/apple/mps/scripts/mps_example.py
@@ -183,9 +183,7 @@
         logging.info(f"Lowered graph:\n{edge.exported_program().graph}")
 
         executorch_program = edge.to_executorch(
-            config=ExecutorchBackendConfig(
-                extract_delegate_segments=False, extract_constant_segment=False
-            )
+            config=ExecutorchBackendConfig(extract_delegate_segments=False)
         )
     else:
         lowered_module = to_backend(
@@ -195,11 +193,7 @@
             lowered_module,
             example_inputs,
             edge_compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
-        ).to_executorch(
-            config=ExecutorchBackendConfig(
-                extract_delegate_segments=False, extract_constant_segment=False
-            )
-        )
+        ).to_executorch(config=ExecutorchBackendConfig(extract_delegate_segments=False))
 
     model_name = f"{args.model_name}_mps"
 
diff --git a/examples/arm/aot_arm_compiler.py b/examples/arm/aot_arm_compiler.py
index f854a08..4d77e81 100644
--- a/examples/arm/aot_arm_compiler.py
+++ b/examples/arm/aot_arm_compiler.py
@@ -226,9 +226,7 @@
 
     try:
         exec_prog = edge.to_executorch(
-            config=ExecutorchBackendConfig(
-                extract_delegate_segments=False, extract_constant_segment=False
-            )
+            config=ExecutorchBackendConfig(extract_delegate_segments=False)
         )
     except RuntimeError as e:
         if "Missing out variants" in str(e.args[0]):
diff --git a/examples/models/llava/export_llava.py b/examples/models/llava/export_llava.py
index 5cd8628..4f8a403 100644
--- a/examples/models/llava/export_llava.py
+++ b/examples/models/llava/export_llava.py
@@ -222,7 +222,6 @@
 
     executorch_program = lowered_and_edge.to_executorch(
         ExecutorchBackendConfig(
-            extract_constant_segment=True,
             extract_delegate_segments=True,
             passes=[
                 QuantFusionPass(),
diff --git a/examples/portable/scripts/export_and_delegate.py b/examples/portable/scripts/export_and_delegate.py
index 8d39453..8df476f 100644
--- a/examples/portable/scripts/export_and_delegate.py
+++ b/examples/portable/scripts/export_and_delegate.py
@@ -15,8 +15,6 @@
     BackendWithCompilerDemo,
 )
 from executorch.exir.backend.test.op_partitioner_demo import AddMulPartitionerDemo
-from executorch.exir.capture._config import ExecutorchBackendConfig
-
 from executorch.extension.export_util import export_to_edge
 
 from ...models import MODEL_NAME_TO_MODEL
@@ -94,9 +92,7 @@
 
     logging.info(f"Lowered graph:\n{composited_edge.exported_program().graph}")
 
-    exec_prog = composited_edge.to_executorch(
-        config=ExecutorchBackendConfig(extract_constant_segment=False)
-    )
+    exec_prog = composited_edge.to_executorch()
     buffer = exec_prog.buffer
 
     model_name = "composite_model"
@@ -147,9 +143,7 @@
     edge = edge.to_backend(AddMulPartitionerDemo())
     logging.info(f"Lowered graph:\n{edge.exported_program().graph}")
 
-    exec_prog = edge.to_executorch(
-        config=ExecutorchBackendConfig(extract_constant_segment=False)
-    )
+    exec_prog = edge.to_executorch()
     buffer = exec_prog.buffer
 
     model_name = "partition_lowered_model"
diff --git a/examples/qualcomm/oss_scripts/llama2/llama.py b/examples/qualcomm/oss_scripts/llama2/llama.py
index 087296b..f7fda3b 100644
--- a/examples/qualcomm/oss_scripts/llama2/llama.py
+++ b/examples/qualcomm/oss_scripts/llama2/llama.py
@@ -315,7 +315,6 @@
             passes=[
                 BuildQuantIo(),
             ],
-            extract_constant_segment=False,
             # For shared buffer, user must pass the memory address
             # which is allocated by RPC memory to executor runner.
             # Therefore, won't want to pre-allocate
diff --git a/examples/qualcomm/scripts/export_example.py b/examples/qualcomm/scripts/export_example.py
index 8339b9f..08f18d6 100644
--- a/examples/qualcomm/scripts/export_example.py
+++ b/examples/qualcomm/scripts/export_example.py
@@ -96,9 +96,7 @@
         )
 
     executorch_program = delegated_program.to_executorch(
-        config=ExecutorchBackendConfig(
-            extract_delegate_segments=False, extract_constant_segment=False
-        )
+        config=ExecutorchBackendConfig(extract_delegate_segments=False)
     )
 
     if args.generate_etrecord:
diff --git a/examples/qualcomm/utils.py b/examples/qualcomm/utils.py
index ef21892..1a748bb 100755
--- a/examples/qualcomm/utils.py
+++ b/examples/qualcomm/utils.py
@@ -254,7 +254,6 @@
     )
 
     executorch_config = ExecutorchBackendConfig(
-        extract_constant_segment=False,
         # For shared buffer, user must pass the memory address
         # which is allocated by RPC memory to executor runner.
         # Therefore, won't want to pre-allocate
diff --git a/examples/sdk/scripts/gen_sample_etrecord.py b/examples/sdk/scripts/gen_sample_etrecord.py
index d2c4913..9194b7c 100644
--- a/examples/sdk/scripts/gen_sample_etrecord.py
+++ b/examples/sdk/scripts/gen_sample_etrecord.py
@@ -4,6 +4,8 @@
 # This source code is licensed under the BSD-style license found in the
 # LICENSE file in the root directory of this source tree.
 
+# pyre-unsafe
+
 # Generate fixture files
 import argparse
 import copy
@@ -18,7 +20,6 @@
     ExportedProgram,
     to_edge,
 )
-from executorch.exir.capture._config import ExecutorchBackendConfig
 from torch.export import export
 
 from ...models import MODEL_NAME_TO_MODEL
@@ -38,9 +39,7 @@
         aten_dialect, compile_config=EdgeCompileConfig(_check_ir_validity=True)
     )
     edge_program_copy = copy.deepcopy(edge_program)
-    et_program: ExecutorchProgramManager = edge_program_copy.to_executorch(
-        config=ExecutorchBackendConfig(extract_constant_segment=False)
-    )
+    et_program: ExecutorchProgramManager = edge_program_copy.to_executorch()
     generate_etrecord(
         (DEFAULT_OUTPUT_PATH if not output_path else output_path),
         edge_dialect_program=edge_program,
diff --git a/examples/xnnpack/aot_compiler.py b/examples/xnnpack/aot_compiler.py
index 32d67e0..0ae84c0 100644
--- a/examples/xnnpack/aot_compiler.py
+++ b/examples/xnnpack/aot_compiler.py
@@ -4,6 +4,8 @@
 # This source code is licensed under the BSD-style license found in the
 # LICENSE file in the root directory of this source tree.
 
+# pyre-unsafe
+
 # Example script for exporting simple models to flatbuffer
 
 import argparse
@@ -103,9 +105,7 @@
     logging.info(f"Lowered graph:\n{edge.exported_program().graph}")
 
     exec_prog = edge.to_executorch(
-        config=ExecutorchBackendConfig(
-            extract_delegate_segments=False, extract_constant_segment=False
-        )
+        config=ExecutorchBackendConfig(extract_delegate_segments=False)
     )
 
     if args.etrecord is not None:
diff --git a/examples/xnnpack/quantization/example.py b/examples/xnnpack/quantization/example.py
index e64c171..bd23f7f 100644
--- a/examples/xnnpack/quantization/example.py
+++ b/examples/xnnpack/quantization/example.py
@@ -4,6 +4,8 @@
 # This source code is licensed under the BSD-style license found in the
 # LICENSE file in the root directory of this source tree.
 
+# pyre-unsafe
+
 import argparse
 import copy
 import logging
@@ -191,9 +193,7 @@
 
     start = time.perf_counter()
     prog = edge_m.to_executorch(
-        config=ExecutorchBackendConfig(
-            extract_delegate_segments=False, extract_constant_segment=False
-        )
+        config=ExecutorchBackendConfig(extract_delegate_segments=False)
     )
     save_pte_program(prog, f"{args.model_name}_quantized")
     end = time.perf_counter()