From e7fad820f7a020edbb6e9270b1c026206d3b2513 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Tue, 6 Aug 2024 16:38:54 -0700 Subject: [PATCH] Move import to quantized --- extension/pybindings/portable_lib.py | 9 --------- kernels/quantized/__init__.py | 21 +++++++++++++++++++++ kernels/quantized/test/test_out_variants.py | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 kernels/quantized/__init__.py diff --git a/extension/pybindings/portable_lib.py b/extension/pybindings/portable_lib.py index 7d04989711..b9ed089f91 100644 --- a/extension/pybindings/portable_lib.py +++ b/extension/pybindings/portable_lib.py @@ -29,15 +29,6 @@ ExecuTorchModule, # noqa: F401 ) - try: - from pathlib import Path - libs = list(Path(__file__).parent.parent.parent.resolve().glob("**/libquantized_ops_aot_lib.*")) - del Path - assert len(libs) == 1, f"Expected 1 library but got {len(libs)}" - _torch.ops.load_library(libs[0]) - except: - pass - # Clean up so that `dir(portable_lib)` is the same as `dir(_portable_lib)` # (apart from some __dunder__ names). del _torch diff --git a/kernels/quantized/__init__.py b/kernels/quantized/__init__.py new file mode 100644 index 0000000000..f8a4e28921 --- /dev/null +++ b/kernels/quantized/__init__.py @@ -0,0 +1,21 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +try: + from pathlib import Path + libs = list(Path(__file__).parent.parent.parent.resolve().glob("**/libquantized_ops_aot_lib.*")) + del Path + assert len(libs) == 1, f"Expected 1 library but got {len(libs)}" + import torch as _torch + _torch.ops.load_library(libs[0]) + del _torch +except: + import logging + logging.info("libquantized_ops_aot_lib is not loaded") + del logging + + + diff --git a/kernels/quantized/test/test_out_variants.py b/kernels/quantized/test/test_out_variants.py index fd7da2a7c3..21ad6fabd9 100644 --- a/kernels/quantized/test/test_out_variants.py +++ b/kernels/quantized/test/test_out_variants.py @@ -14,6 +14,7 @@ quantized_decomposed_lib, # noqa ) +import executorch.kernels.quantized class TestOutVariants(unittest.TestCase): def setUp(self) -> None: