Returns a list of passes to run before memory planning. Get the sym shape eval pass based on the method name, if the pass is not in the dict, use the default pass.
(
config: ExecutorchBackendConfig, name: Optional[str] = None
)
| 802 | |
| 803 | |
| 804 | def pre_memory_planning_passes( |
| 805 | config: ExecutorchBackendConfig, name: Optional[str] = None |
| 806 | ) -> List[PassType]: |
| 807 | """ |
| 808 | Returns a list of passes to run before memory planning. |
| 809 | Get the sym shape eval pass based on the method name, if the pass is not in the dict, use the default pass. |
| 810 | """ |
| 811 | # Handle symbolic shape eval pass |
| 812 | if isinstance(config.sym_shape_eval_pass, dict): |
| 813 | default_pass = ExecutorchBackendConfig().sym_shape_eval_pass |
| 814 | if not name: |
| 815 | sym_shape_eval_pass = default_pass |
| 816 | # pyre-ignore: Undefined attribute [16] |
| 817 | sym_shape_eval_pass = config.sym_shape_eval_pass.get(name, default_pass) |
| 818 | elif isinstance(config.sym_shape_eval_pass, PassBase): |
| 819 | sym_shape_eval_pass = config.sym_shape_eval_pass |
| 820 | else: |
| 821 | raise RuntimeError( |
| 822 | f"sym_shape_eval_pass must be a dict or a PassBase, got {config.sym_shape_eval_pass}" |
| 823 | ) |
| 824 | if config.remove_view_copy: |
| 825 | return [ |
| 826 | NormalizeViewCopyBasePass(), |
| 827 | dead_code_elimination_pass, |
| 828 | ReplaceViewCopyWithViewPass(), |
| 829 | sym_shape_eval_pass, |
| 830 | config.to_out_var_pass, |
| 831 | ] |
| 832 | else: |
| 833 | return [ |
| 834 | sym_shape_eval_pass, |
| 835 | config.to_out_var_pass, |
| 836 | ] |
| 837 | |
| 838 | |
| 839 | def edge_to_executorch_passes( |
no test coverage detected