Skip to content

Commit

Permalink
Redefine FBGEMM targets with gpu_cpp_library [6/N] (pytorch#3092)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#3092

X-link: facebookresearch/FBGEMM#185

- Redefine `split_table_batched_embeddings_gpu` target with `gpu_cpp_library`

Reviewed By: spcyppt

Differential Revision: D62282866

fbshipit-source-id: 217251a2ca2ff2502bb97f2b67ef07b15f5ccedc
  • Loading branch information
q10 authored and facebook-github-bot committed Sep 7, 2024
1 parent 3fce106 commit 20e49a9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
18 changes: 7 additions & 11 deletions fbgemm_gpu/bench/split_embeddings_cache_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import click
import numpy as np
import torch

from fbgemm_gpu.split_embedding_configs import SparseType
from fbgemm_gpu.split_table_batched_embeddings_ops_common import (
CacheAlgorithm,
Expand All @@ -23,6 +22,8 @@
IntNBitTableBatchedEmbeddingBagsCodegen,
)

from fbgemm_gpu.utils.loader import load_torch_module

from torch import nn, Tensor

logging.basicConfig(level=logging.DEBUG)
Expand All @@ -31,16 +32,11 @@
# pyre-ignore[21]
from fbgemm_gpu import open_source # noqa: F401
except Exception:
if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:cumem_utils_hip")
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings_hip"
)
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:cumem_utils")
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings"
)
for module in [
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings",
"//deeplearning/fbgemm/fbgemm_gpu:cumem_utils",
]:
load_torch_module(module)


# pyre-ignore
Expand Down
13 changes: 4 additions & 9 deletions fbgemm_gpu/bench/ssd_table_batched_embeddings_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,15 @@
SSDTableBatchedEmbeddingBags,
)
from fbgemm_gpu.tbe.utils import generate_requests, get_device, round_up, TBERequest
from fbgemm_gpu.utils.loader import load_torch_module
from torch.autograd.profiler import record_function
from torch.profiler import profile

logging.basicConfig(level=logging.DEBUG)

if torch.version.hip:
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:ssd_split_table_batched_embeddings_hip"
)
else:
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:ssd_split_table_batched_embeddings"
)

load_torch_module(
"//deeplearning/fbgemm/fbgemm_gpu:ssd_split_table_batched_embeddings",
)

logging.basicConfig(level=logging.DEBUG)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ _load_library(
"//deeplearning/fbgemm/fbgemm_gpu/codegen:optimizer_ops_hip",
)

_load_library(
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings",
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings",
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings_hip",
)

if torch.version.hip:
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings_hip"
)
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu/codegen:embedding_ops_hip_training"
)
else:
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:split_table_batched_embeddings"
)
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu/codegen:embedding_ops_cuda_training"
)

{%- endif %}


Expand Down

0 comments on commit 20e49a9

Please sign in to comment.