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
13 changes: 11 additions & 2 deletions extension/llm/custom_ops/custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# pyre-unsafe

import logging
from pathlib import Path

import torch

Expand All @@ -23,7 +22,17 @@
op2 = torch.ops.llama.fast_hadamard_transform.default
assert op2 is not None
except:
libs = list(Path(__file__).parent.resolve().glob("libcustom_ops_aot_lib.*"))
import glob

import executorch

executorch_package_path = executorch.__path__[0]
logging.info(f"Looking for libcustom_ops_aot_lib.so in {executorch_package_path}")
libs = list(
glob.glob(
f"{executorch_package_path}/**/libcustom_ops_aot_lib.*", recursive=True
)
)
assert len(libs) == 1, f"Expected 1 library but got {len(libs)}"
logging.info(f"Loading custom ops library: {libs[0]}")
torch.ops.load_library(libs[0])
Expand Down