1# Copyright (c) Meta Platforms, Inc. and affiliates. 2# All rights reserved. 3# 4# This source code is licensed under the BSD-style license found in the 5# LICENSE file in the root directory of this source tree. 6 7# pyre-strict 8 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 16import warnings as _warnings 17 18import 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 25# When installed as a pip wheel, we must import `torch` before trying to import 26# the pybindings shared library extension. This will load libtorch.so and 27# related libs, ensuring that the pybindings lib can resolve those runtime 28# dependencies. 29import torch as _torch 30 31# Let users import everything from the C++ _portable_lib extension as if this 32# python file defined them. Although we could import these dynamically, it 33# wouldn't preserve the static type annotations. 34# 35# Note that all of these are experimental, and subject to change without notice. 36from executorch.extension.pybindings._portable_lib import ( # noqa: F401 37 # Disable "imported but unused" (F401) checks. 38 _create_profile_block, # noqa: F401 39 _dump_profile_results, # noqa: F401 40 _get_operator_names, # noqa: F401 41 _load_bundled_program_from_buffer, # noqa: F401 42 _load_for_executorch, # noqa: F401 43 _load_for_executorch_from_buffer, # noqa: F401 44 _load_for_executorch_from_bundled_program, # noqa: F401 45 _reset_profile_results, # noqa: F401 46 BundledModule, # noqa: F401 47 ExecuTorchModule, # noqa: F401 48 MethodMeta, # noqa: F401 49 Verification, # noqa: F401 50) 51 52# Clean up so that `dir(portable_lib)` is the same as `dir(_portable_lib)` 53# (apart from some __dunder__ names). 54del _torch 55del _exir_warnings 56del _warnings 57