Skip to content
Merged
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: 15 additions & 2 deletions backends/cadence/aot/ref_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@
import torch
import torch.nn as nn
import torch.nn.functional as F

from executorch.exir.scalar_type import ScalarType
from torch.library import impl, Library

m = Library("cadence", "IMPL", "CompositeExplicitAutograd")
torch.ops.load_library("//executorch/kernels/quantized:custom_ops_generated_lib")

try:
torch.ops.load_library("//executorch/kernels/quantized:custom_ops_generated_lib")
except (OSError, RuntimeError):
# Fall back to path-based loading for CMake/OSS builds
from pathlib import Path

custom_libs: list[Path] = list(
Path(__file__)
.parent.parent.parent.resolve()
.glob("**/kernels/quantized/**/*custom_ops_generated_lib.*")
)
if custom_libs:
torch.ops.load_library(str(custom_libs[0]))
del Path

# Registry to track all ops with reference implementations
_REGISTERED_REF_IMPLEMENTATIONS: set[str] = set()
Expand Down
Loading