You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/using-executorch-runtime-integration.md
+41-1Lines changed: 41 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,47 @@ For non-POSIX-compliant systems, a minimal no-op PAL implementation is provided.
24
24
25
25
### Overriding the PAL
26
26
27
-
Overriding the default PAL implementation is commonly done to route logs to a user-specified destination or to provide PAL functionality on embedded systems. To override one or more PAL methods, take the following steps:
27
+
Overriding the default PAL implementation is commonly done to route logs to a user-specified destination or to provide PAL functionality on embedded systems. The PAL can be overriden usinn runtime APIs or at link time. Prefer the runtime API unless you specifically need link-time overrides.
28
+
29
+
### Runtime PAL Registration
30
+
31
+
To register a custom PAL implementation, take the following steps:
in one of your application's `.c` or `.cpp` files.
36
+
- Create an instance of the [PalImpl](https://github.com/pytorch/executorch/blob/7b39a0ce63bfb5124d4d29cfb6c8af85a3c580ba/runtime/platform/platform.h#L163) struct.
37
+
- Set one or more fields to custom PAL function implementations. Leave fields as null to use the default platform implementation.
38
+
- The PalImpl struct provides a [create](https://github.com/pytorch/executorch/blob/7b39a0ce63bfb5124d4d29cfb6c8af85a3c580ba/runtime/platform/platform.h#L168) method for this purpose.
39
+
- Call `executorch::platform::register_pal(pal_impl)` to register the implementation.
40
+
- This can be done from a static context, as in the example below.
41
+
42
+
Here is a complete example from [pybindings.cpp](https://github.com/pytorch/executorch/blob/7b39a0ce63bfb5124d4d29cfb6c8af85a3c580ba/extension/pybindings/pybindings.cpp#L4), where logs are redirected to show up properly in a Python notebook environment.
0 commit comments