Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions fla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@

from pkgutil import extend_path

import paddle

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard the Paddle-only compatibility hook

When Paddle is not separately installed—as with every documented [cuda], [rocm], [xpu], [npu], and [cpu] installation, since pyproject.toml does not declare it—this top-level import raises ModuleNotFoundError before any FLA API can load; this is reproducible with a plain import fla. Install the compatibility override only when running through Paddle compatibility rather than making Paddle mandatory for every backend.

AGENTS.md reference: AGENTS.md:L40-L41

Useful? React with 👍 / 👎.


__path__ = extend_path(__path__, __name__)
__version__ = "0.5.2"


def _torch_compat_empty(*args, **kwargs):
if kwargs.get("device") == "cuda":
del kwargs["device"]
return paddle.empty(*args, **kwargs)
Comment on lines +16 to +19


paddle.compat.proxy._extend_torch_proxy_overrides(
{
"torch.empty": paddle.compat.proxy.RawOverriddenAttribute(
_torch_compat_empty
),
}
)

from fla import modules, ops # noqa: E402

__all__ = ["modules", "ops"]