From 204b8e02d2297b3930e66912d67f9b42079a3b54 Mon Sep 17 00:00:00 2001 From: Max Ren Date: Tue, 1 Apr 2025 13:54:18 -0700 Subject: [PATCH] [ExecuTorch][to_backend] Introduce preprocess_all method to backend details We introduce the new static method preprocess_all. This is not an enforced method because preprocess() is enforced and can be used instead. Ideally, I want the default implementation of preprocess_all, to just loop through the exported programs for each method and use preprocess() to lower them. However since each are static methods, I wasn't able to find a good way to do this. Suggestions would be greatly appreciated for that. Differential Revision: [D69954544](https://our.internmc.facebook.com/intern/diff/D69954544/) [ghstack-poisoned] --- exir/backend/backend_details.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/exir/backend/backend_details.py b/exir/backend/backend_details.py index 248d03f2b05..c3973313a74 100644 --- a/exir/backend/backend_details.py +++ b/exir/backend/backend_details.py @@ -73,3 +73,12 @@ def preprocess( # Users should return a compiled blob - a binary that can run the desired # program in the backend. pass + + @staticmethod + # it's a virtual method and inheritant class needs to implement the actual function + @abstractmethod + def preprocess_all( + edge_programs: Dict[str, List[ExportedProgram]], + compile_specs: Dict[str, List[List[CompileSpec]]], + ) -> Dict[str, list[PreprocessResult]]: + pass