|
17 | 17 | import shlex |
18 | 18 | from enum import Enum |
19 | 19 | from functools import partial |
| 20 | + |
| 21 | +from importlib import resources as _resources |
20 | 22 | from json import JSONDecodeError |
21 | 23 | from pathlib import Path |
22 | 24 | from typing import Callable, List, Optional, Union |
23 | 25 |
|
24 | | -import pkg_resources |
25 | 26 | import torch |
26 | 27 |
|
27 | 28 | from executorch.devtools.backend_debug import print_delegation_info |
28 | | - |
29 | 29 | from executorch.devtools.etrecord import generate_etrecord as generate_etrecord_func |
30 | 30 | from executorch.examples.models.llama.hf_download import ( |
31 | 31 | download_and_convert_hf_checkpoint, |
32 | 32 | ) |
33 | 33 | from executorch.exir.passes.init_mutable_pass import InitializedMutableBufferPass |
34 | | - |
35 | 34 | from executorch.extension.llm.export.builder import DType, LLMEdgeManager |
36 | | - |
37 | 35 | from executorch.extension.llm.export.config.llm_config import LlmConfig |
38 | | - |
39 | 36 | from executorch.extension.llm.export.partitioner_lib import ( |
40 | 37 | get_coreml_partitioner, |
41 | 38 | get_mps_partitioner, |
42 | 39 | get_qnn_partitioner, |
43 | 40 | get_vulkan_partitioner, |
44 | 41 | get_xnnpack_partitioner, |
45 | 42 | ) |
46 | | - |
47 | 43 | from executorch.extension.llm.export.quantizer_lib import ( |
48 | 44 | get_coreml_quantizer, |
49 | 45 | get_pt2e_quantization_params, |
|
52 | 48 | get_vulkan_quantizer, |
53 | 49 | ) |
54 | 50 | from executorch.util.activation_memory_profiler import generate_memory_trace |
55 | | - |
56 | 51 | from omegaconf import DictConfig |
57 | 52 |
|
58 | 53 | from ..model_factory import EagerModelFactory |
59 | 54 | from .source_transformation.apply_spin_quant_r1_r2 import ( |
60 | 55 | fuse_layer_norms, |
61 | 56 | get_model_with_r1_r2, |
62 | 57 | ) |
63 | | - |
64 | 58 | from .source_transformation.attention import replace_attention_to_attention_sha |
65 | 59 | from .source_transformation.custom_kv_cache import ( |
66 | 60 | replace_kv_cache_with_custom_kv_cache, |
67 | 61 | replace_kv_cache_with_quantized_kv_cache, |
68 | 62 | replace_kv_cache_with_ring_kv_cache, |
69 | 63 | ) |
70 | | - |
71 | 64 | from .source_transformation.quantize import ( |
72 | 65 | get_quant_embedding_transform, |
73 | 66 | get_quant_weight_transform, |
@@ -129,7 +122,7 @@ def set_pkg_name(name: str) -> None: |
129 | 122 |
|
130 | 123 |
|
131 | 124 | def get_resource_path(resource_name) -> str: |
132 | | - return pkg_resources.resource_filename(pkg_name, resource_name) |
| 125 | + return str(_resources.files(pkg_name).joinpath(resource_name)) |
133 | 126 |
|
134 | 127 |
|
135 | 128 | def set_verbosity(val): |
@@ -575,7 +568,7 @@ def canonical_path(path: Union[str, Path], *, dir: bool = False) -> str: |
575 | 568 | print("not FBCODE") |
576 | 569 | return path[4:] |
577 | 570 | else: |
578 | | - return_val = pkg_resources.resource_filename(pkg_name, path[4:]) |
| 571 | + return_val = str(_resources.files(pkg_name).joinpath(path[4:])) |
579 | 572 | if verbose_export(): |
580 | 573 | print(f"canonical name is: {return_val}") |
581 | 574 | return return_val |
|
0 commit comments