1010# this form is used where the final JIT compile is performed on target (in the
1111# runtime delegate executorch::runtime::BackendInterface::init
1212#
13+ """Ahead-of-time Arm VGF backend built on the shared TOSA pipeline."""
1314
1415import logging
1516import os
4344
4445@final
4546class VgfBackend (BackendDetails ):
46- """
47- BackendDetails subclass for delegation to VGF compatible devices. This enables
48- encapsulated TOSA on target device and JIT compilation on suitable platforms.
47+ """BackendDetails subclass for delegation to VGF compatible devices.
48+
49+ This enables encapsulated TOSA on target device and JIT compilation on
50+ suitable platforms.
51+
4952 """
5053
5154 @staticmethod
@@ -54,9 +57,18 @@ def _compile_tosa_flatbuffer(
5457 compile_spec : VgfCompileSpec ,
5558 tag_name : str = "" ,
5659 ) -> bytes :
57- """
58- Static helper method to do the compilation of the TOSA flatbuffer
59- representation to a target specific binary stream.
60+ """Compile a TOSA flatbuffer into a target-specific binary stream.
61+
62+ Args:
63+ tosa_flatbuffer (bytes): Serialized TOSA graph produced by
64+ ``TOSABackend``.
65+ compile_spec (VgfCompileSpec): Compile specification providing
66+ converter flags and artifact paths.
67+ tag_name (str): Optional suffix used when producing debug outputs.
68+
69+ Returns:
70+ bytes: Target-specific VGF binary stream.
71+
6072 """
6173 compile_flags = compile_spec .compiler_flags
6274 artifact_path = compile_spec .get_intermediate_path ()
@@ -69,6 +81,17 @@ def preprocess(
6981 edge_program : ExportedProgram ,
7082 compile_specs : List [CompileSpec ],
7183 ) -> PreprocessResult :
84+ """Lower the exported program and compile it for a VGF target.
85+
86+ Args:
87+ edge_program (ExportedProgram): Program to lower to VGF.
88+ compile_specs (List[CompileSpec]): Serialized VGF compile specs
89+ supplied by the frontend.
90+
91+ Returns:
92+ PreprocessResult: Result containing the compiled VGF binary.
93+
94+ """
7295 logger .info (f"{ VgfBackend .__name__ } preprocess" )
7396
7497 compile_spec = VgfCompileSpec .from_list (compile_specs )
@@ -98,6 +121,20 @@ def vgf_compile(
98121 artifact_path : str | None = None ,
99122 tag_name : str = "" ,
100123):
124+ """Invoke the VGF compiler to convert a TOSA flatbuffer.
125+
126+ Args:
127+ tosa_flatbuffer (bytes): Serialized TOSA graph produced by
128+ ``TOSABackend``.
129+ compile_flags (List[str]): Command-line flags forwarded to
130+ ``model-converter``.
131+ artifact_path (str | None): Directory where debug artifacts are saved.
132+ tag_name (str): Optional suffix used when producing debug outputs.
133+
134+ Returns:
135+ bytes: Compiled VGF binary emitted by ``model-converter``.
136+
137+ """
101138 with tempfile .TemporaryDirectory () as tmpdir :
102139
103140 # We currently write out a flatbuffer as input to the converter
0 commit comments