Dynamic Function Selection Process in PyTorch Compilation for torch_cpu.so”

risemeup1: <p>During the compilation of torch_cpu.so in PyTorch, the source code files are categorized into avx_srcs, avx2_srcs, avx512_srcs, and common_srcs. Each category of files is then compiled into a separate static library. Finally, these static libraries are linked together to create libtorch_cpu.so. At runtime, the process of dynamically selecting which function to call is a crucial step. I would like to know how this dynamic selection process works and where in the codebase it is implemented.could u plz show where the code is?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/7/274979df051e2c77531d349b6e73876298dc0fd7.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/274979df051e2c77531d349b6e73876298dc0fd7" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/274979df051e2c77531d349b6e73876298dc0fd7_2_690x442.jpeg" alt="image" data-base62-sha1="5By2FANU4Bq162Eoesd0RevWesT" width="690" height="442" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/274979df051e2c77531d349b6e73876298dc0fd7_2_690x442.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/274979df051e2c77531d349b6e73876298dc0fd7_2_1035x663.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/274979df051e2c77531d349b6e73876298dc0fd7_2_1380x884.jpeg 2x" data-dominant-color="F6F6F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1906×1222 135 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/4/c4326658fa551dd571a5c5f00e703b628174b138.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/c4326658fa551dd571a5c5f00e703b628174b138" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4326658fa551dd571a5c5f00e703b628174b138_2_690x335.jpeg" alt="image" data-base62-sha1="rZDz2TXp7kipCJdiLoyxon5WFyU" width="690" height="335" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4326658fa551dd571a5c5f00e703b628174b138_2_690x335.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4326658fa551dd571a5c5f00e703b628174b138_2_1035x502.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4326658fa551dd571a5c5f00e703b628174b138_2_1380x670.jpeg 2x" data-dominant-color="EFECEE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1640×798 124 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
When users utilize libtorch_cpu.so, how do they decide which function to use? Taking the example of caffe2/perfkernels/embedding_lookup_idx_avx2.cc, where is the decision made to call either EmbeddingLookupIdx_int32_t_float_float_true__avx2_fma or EmbeddingLookupGenericSlowIdx function?</p>