|
77 | 77 |
|
78 | 78 | from torch.library import Library
|
79 | 79 |
|
| 80 | +from typing import Callable, Any |
| 81 | +try: |
| 82 | + from executorch.exir.program.fb.logger import et_logger |
| 83 | +except ImportError: |
| 84 | + # Define a stub decorator that does nothing |
| 85 | + def et_logger(api_name: str) -> Callable[[Any], Any]: |
| 86 | + def decorator(func: Callable[..., Any]) -> Callable[..., Any]: |
| 87 | + def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: |
| 88 | + return func(self, *args, **kwargs) |
| 89 | + return wrapper |
| 90 | + return decorator |
| 91 | + |
80 | 92 | # This is the reserved namespace that is used to register ops to that will
|
81 | 93 | # be prevented from being decomposed during to_edge_transform_and_lower.
|
82 | 94 | edge_no_decomp_namespace = "EDGE_DO_NOT_DECOMP"
|
@@ -956,7 +968,7 @@ def _gen_edge_manager_for_partitioners(
|
956 | 968 | )
|
957 | 969 | return edge_manager
|
958 | 970 |
|
959 |
| - |
| 971 | +@et_logger("to_edge_transform_and_lower") |
960 | 972 | def to_edge_transform_and_lower(
|
961 | 973 | programs: Union[ExportedProgram, Dict[str, ExportedProgram]],
|
962 | 974 | transform_passes: Optional[
|
@@ -1109,7 +1121,7 @@ def to_edge_with_preserved_ops(
|
1109 | 1121 | edge_programs, constant_methods, config, list(preserve_ops)
|
1110 | 1122 | )
|
1111 | 1123 |
|
1112 |
| - |
| 1124 | +@et_logger("to_edge") |
1113 | 1125 | def to_edge(
|
1114 | 1126 | programs: Union[ExportedProgram, Dict[str, ExportedProgram]],
|
1115 | 1127 | constant_methods: Optional[Dict[str, Any]] = None,
|
@@ -1204,8 +1216,10 @@ def exported_program(self, method_name: str = "forward") -> ExportedProgram:
|
1204 | 1216 | """
|
1205 | 1217 | Returns the ExportedProgram specified by 'method_name'.
|
1206 | 1218 | """
|
| 1219 | + |
1207 | 1220 | return self._edge_programs[method_name]
|
1208 | 1221 |
|
| 1222 | + @et_logger("transform") |
1209 | 1223 | def transform(
|
1210 | 1224 | self,
|
1211 | 1225 | passes: Union[Sequence[PassType], Dict[str, Sequence[PassType]]],
|
@@ -1253,6 +1267,7 @@ def transform(
|
1253 | 1267 | new_programs, copy.deepcopy(self._config_methods), compile_config
|
1254 | 1268 | )
|
1255 | 1269 |
|
| 1270 | + @et_logger("to_backend") |
1256 | 1271 | def to_backend(
|
1257 | 1272 | self, partitioner: Union[Partitioner, Dict[str, Partitioner]]
|
1258 | 1273 | ) -> "EdgeProgramManager":
|
@@ -1296,6 +1311,7 @@ def to_backend(
|
1296 | 1311 | new_edge_programs, copy.deepcopy(self._config_methods), config
|
1297 | 1312 | )
|
1298 | 1313 |
|
| 1314 | + @et_logger("to_executorch") |
1299 | 1315 | def to_executorch(
|
1300 | 1316 | self,
|
1301 | 1317 | config: Optional[ExecutorchBackendConfig] = None,
|
|
0 commit comments