[Executorch][custom ops] Change lib loading logic to account for package dir (#7211)
Pull Request resolved: https://github.com/pytorch/executorch/pull/7038 Just looking at the location of the source file. In this case custom_ops.py, can, and does, yield to wrong location depending on where you import custom_ops from. If you are importing custom_ops from another source file inside extension folder, e.g. builder.py that is in extensions/llm/export, then, I think, custom_ops gets resolved to the one installed in site-packages or pip package. But if this is imported from say examples/models/llama/source_transformations/quantized_kv_cache.py (Like in the in next PR), then it seems to resolve to the source location. In one of the CI this is /pytorch/executorch. Now depending on which directory your filepath resolves to, you will search for lib in that. This of course does not work when filepath resolves to source location. This PR changes that to resolve to package location. ghstack-source-id: 256711930 //unit-test-arm broken in trunk @bypass-github-export-checks @exported-using-ghexport Differential Revision: [D66385480](https://our.internmc.facebook.com/intern/diff/D66385480/) Co-authored-by: Kimish Patel <kimishpatel@fb.com>
P
pytorchbot committed
97a745269aeb3e50c3c71934fd4f721d1914dfee
Parent: 0913099
Committed by GitHub <noreply@github.com>
on 12/6/2024, 10:46:00 PM