Skip to content

Commit 1bb5b20

Browse files
dbortfacebook-github-bot
authored andcommitted
Mark all pybindings.portable_lib names as @experimental (#5329)
Summary: Pull Request resolved: #5329 We plan to replace this with a new API, but it's not likely to happen for beta. Mark this as experimental to set expectations better. Turns out that decorating the `.pyi` file doesn't actually raise any warnings, but doing so will be more clear to users who read it. Reviewed By: mergennachin, larryliu0820 Differential Revision: D62608680 fbshipit-source-id: a43cc71a0d3d84078c3dd640ca958f21c2f5aef2
1 parent bba4040 commit 1bb5b20

File tree

3 files changed

+105
-8
lines changed

3 files changed

+105
-8
lines changed

extension/pybindings/portable_lib.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66

77
# pyre-strict
88

9+
"""API for loading and executing ExecuTorch PTE files using the C++ runtime.
10+
11+
.. warning::
12+
13+
This API is experimental and subject to change without notice.
14+
"""
15+
16+
import warnings as _warnings
17+
18+
import executorch.exir._warnings as _exir_warnings
19+
20+
_warnings.warn(
21+
"This API is experimental and subject to change without notice.",
22+
_exir_warnings.ExperimentalWarning,
23+
)
24+
925
# When installed as a pip wheel, we must import `torch` before trying to import
1026
# the pybindings shared library extension. This will load libtorch.so and
1127
# related libs, ensuring that the pybindings lib can resolve those runtime
@@ -15,6 +31,8 @@
1531
# Let users import everything from the C++ _portable_lib extension as if this
1632
# python file defined them. Although we could import these dynamically, it
1733
# wouldn't preserve the static type annotations.
34+
#
35+
# Note that all of these are experimental, and subject to change without notice.
1836
from executorch.extension.pybindings._portable_lib import ( # noqa: F401
1937
# Disable "imported but unused" (F401) checks.
2038
_create_profile_block, # noqa: F401
@@ -32,3 +50,5 @@
3250
# Clean up so that `dir(portable_lib)` is the same as `dir(_portable_lib)`
3351
# (apart from some __dunder__ names).
3452
del _torch
53+
del _exir_warnings
54+
del _warnings

extension/pybindings/pybindings.pyi

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
# pyre-strict
88
from typing import Any, Dict, List, Optional, Sequence, Tuple
99

10+
from executorch.exir._warnings import experimental
11+
12+
@experimental("This API is experimental and subject to change without notice.")
1013
class ExecuTorchModule:
14+
"""ExecuTorchModule is a Python wrapper around a C++ ExecuTorch program.
15+
16+
.. warning::
17+
18+
This API is experimental and subject to change without notice.
19+
"""
20+
1121
# pyre-ignore[2, 3]: "Any" in parameter and return type annotations.
1222
def __call__(self, inputs: Any) -> List[Any]: ...
1323
# pyre-ignore[2, 3]: "Any" in parameter and return type annotations.
@@ -34,12 +44,26 @@ class ExecuTorchModule:
3444
self, path: str, debug_buffer_path: Optional[str] = None
3545
) -> None: ...
3646

37-
class BundledModule: ...
47+
@experimental("This API is experimental and subject to change without notice.")
48+
class BundledModule:
49+
"""
50+
.. warning::
3851
52+
This API is experimental and subject to change without notice.
53+
"""
54+
55+
...
56+
57+
@experimental("This API is experimental and subject to change without notice.")
3958
def _load_for_executorch(
4059
path: str, enable_etdump: bool = False, debug_buffer_size: int = 0
4160
) -> ExecuTorchModule:
4261
"""Load an ExecuTorch Program from a file.
62+
63+
.. warning::
64+
65+
This API is experimental and subject to change without notice.
66+
4367
Args:
4468
path: File path to the ExecuTorch program as a string.
4569
enable_etdump: If true, enables an ETDump which can store profiling information.
@@ -53,23 +77,75 @@ def _load_for_executorch(
5377
"""
5478
...
5579

80+
@experimental("This API is experimental and subject to change without notice.")
5681
def _load_for_executorch_from_buffer(
5782
buffer: bytes, enable_etdump: bool = False, debug_buffer_size: int = 0
5883
) -> ExecuTorchModule:
59-
"""Same as _load_for_executorch, but takes a byte buffer instead of a file path."""
84+
"""Same as _load_for_executorch, but takes a byte buffer instead of a file path.
85+
86+
.. warning::
87+
88+
This API is experimental and subject to change without notice.
89+
"""
6090
...
6191

92+
@experimental("This API is experimental and subject to change without notice.")
6293
def _load_for_executorch_from_bundled_program(
6394
module: BundledModule, enable_etdump: bool = False, debug_buffer_size: int = 0
6495
) -> ExecuTorchModule:
6596
"""Same as _load_for_executorch, but takes a bundled program instead of a file path.
66-
See https://pytorch.org/executorch/stable/sdk-bundled-io.html for documentation."""
97+
98+
See https://pytorch.org/executorch/stable/sdk-bundled-io.html for documentation.
99+
100+
.. warning::
101+
102+
This API is experimental and subject to change without notice.
103+
"""
67104
...
68105

106+
@experimental("This API is experimental and subject to change without notice.")
69107
def _load_bundled_program_from_buffer(
70108
buffer: bytes, non_const_pool_size: int = ...
71-
) -> BundledModule: ...
72-
def _get_operator_names() -> List[str]: ...
73-
def _create_profile_block(name: str) -> None: ...
74-
def _dump_profile_results() -> bytes: ...
75-
def _reset_profile_results() -> None: ...
109+
) -> BundledModule:
110+
"""
111+
.. warning::
112+
113+
This API is experimental and subject to change without notice.
114+
"""
115+
...
116+
117+
@experimental("This API is experimental and subject to change without notice.")
118+
def _get_operator_names() -> List[str]:
119+
"""
120+
.. warning::
121+
122+
This API is experimental and subject to change without notice.
123+
"""
124+
...
125+
126+
@experimental("This API is experimental and subject to change without notice.")
127+
def _create_profile_block(name: str) -> None:
128+
"""
129+
.. warning::
130+
131+
This API is experimental and subject to change without notice.
132+
"""
133+
...
134+
135+
@experimental("This API is experimental and subject to change without notice.")
136+
def _dump_profile_results() -> bytes:
137+
"""
138+
.. warning::
139+
140+
This API is experimental and subject to change without notice.
141+
"""
142+
...
143+
144+
@experimental("This API is experimental and subject to change without notice.")
145+
def _reset_profile_results() -> None:
146+
"""
147+
.. warning::
148+
149+
This API is experimental and subject to change without notice.
150+
"""
151+
...

shim/xplat/executorch/extension/pybindings/pybindings.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def executorch_pybindings(python_module_name, srcs = [], cppdeps = [], visibilit
5252
"-DEXECUTORCH_PYTHON_MODULE_NAME={}".format(python_module_name),
5353
],
5454
deps = [
55+
"//executorch/exir:_warnings",
5556
"//executorch/runtime/core:core",
5657
] + cppdeps,
5758
external_deps = [

0 commit comments

Comments
 (0)