Skip to content

Commit

Permalink
Use gpu_library_selector for permute_pooled_embedding_ops_gpu (#1799)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/FBGEMM#2435

Pull Request resolved: #1799

Using gpu_library_selector can avoid divergence in the usercode

A few notable changes:
* the original permute_pooled_embedding_ops_gpu is missing link_whole
* Make permute_pooled_embedding_function.cpp as its own library. This is because permute_pooled_embedding_function.cpp is included in both permute_pooled_embedding_ops_gpu and permute_pooled_embedding_ops_cpu. So when we link the _cpu and _gpu together, it'll complain about duplicate symbol.

Reviewed By: houseroad

Differential Revision: D54986292

fbshipit-source-id: b029c689eaf5f143b6d0b710aa30a06d1dd141f5
  • Loading branch information
xw285cornell authored and facebook-github-bot committed Mar 18, 2024
1 parent 7fb1d62 commit ce7b919
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions torchrec/distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,9 @@
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_pooled_embedding_ops_cpu"
)
try:
if torch.version.hip:
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_pooled_embedding_ops_gpu_hip"
)
else:
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_pooled_embedding_ops_gpu_cuda"
)
except OSError:
# For backward compatibility
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_pooled_embedding_ops_gpu"
)
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_pooled_embedding_ops_gpu"
)
except OSError:
pass

Expand Down

0 comments on commit ce7b919

Please sign in to comment.