Skip to content

Commit

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

X-link: facebookresearch/FBGEMM#299

- Combine `gpu_cpp_library` targets into `fbgemm_gpu:sparse_ops`

Reviewed By: gag1jain

Differential Revision: D63679169
  • Loading branch information
q10 authored and facebook-github-bot committed Oct 1, 2024
1 parent b907f32 commit e589027
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 65 deletions.
6 changes: 1 addition & 5 deletions fbgemm_gpu/bench/batched_unary_embeddings_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
else:
from fbgemm_gpu.bench.bench_utils import benchmark_torch_function

if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


def generate_unary_feature(
Expand Down
6 changes: 1 addition & 5 deletions fbgemm_gpu/bench/histogram_binning_calibration_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
# 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:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


def benchmark_hbc_function(
Expand Down
6 changes: 1 addition & 5 deletions fbgemm_gpu/bench/jagged_tensor_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
else:
from fbgemm_gpu.bench.bench_utils import benchmark_torch_function

if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_pooled_embedding_ops_cpu"
)
Expand All @@ -47,7 +44,6 @@
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:permute_multi_embedding_ops_gpu"
)
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")


@click.group()
Expand Down
6 changes: 1 addition & 5 deletions fbgemm_gpu/bench/quantize_ops_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
else:
from fbgemm_gpu.bench.bench_utils import benchmark_torch_function

if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


@click.group()
Expand Down
6 changes: 1 addition & 5 deletions fbgemm_gpu/bench/stride_gemm_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
# 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:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


@click.group()
Expand Down
9 changes: 3 additions & 6 deletions fbgemm_gpu/fbgemm_gpu/batched_unary_embeddings_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@

import torch

from fbgemm_gpu.utils.loader import load_torch_module

try:
# 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:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
load_torch_module("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


def wrap_weight_to_parameter(weights: List[torch.Tensor]) -> List[torch.Tensor]:
Expand Down
4 changes: 1 addition & 3 deletions fbgemm_gpu/fbgemm_gpu/sparse_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@
from fbgemm_gpu import open_source # noqa: F401
except Exception:
load_torch_module("//deeplearning/fbgemm/fbgemm_gpu:merge_pooled_embeddings")
load_torch_module("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu/codegen:embedding_ops_hip"
)

else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu/codegen:embedding_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:input_combine")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library(
"//deeplearning/fbgemm/fbgemm_gpu:merge_pooled_embeddings_cpu"
)
Expand Down
8 changes: 2 additions & 6 deletions fbgemm_gpu/test/batched_unary_embeddings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@
from test_utils import gpu_unavailable

except Exception:
if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
from fbgemm_gpu.test.test_utils import gpu_unavailable

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


# Relative tolerances
# pyre-fixme[5]: Global expression must be annotated.
Expand Down
8 changes: 1 addition & 7 deletions fbgemm_gpu/test/jagged/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
open_source: bool = getattr(fbgemm_gpu, "open_source", False)

if not open_source:
if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

suppressed_list: List[HealthCheck] = (
[HealthCheck.differing_executors]
Expand Down
8 changes: 2 additions & 6 deletions fbgemm_gpu/test/layout_transform_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@
from test_utils import gpu_unavailable

except Exception:
if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
from fbgemm_gpu.test.test_utils import gpu_unavailable

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")


MAX_EXAMPLES = 20

Expand Down
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/quantize/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
from fbgemm_gpu import open_source # noqa: F401

except Exception:
if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

# Eigen/Python round 0.5 away from 0, Numpy rounds to even
round_to_nearest: Callable[[npt.NDArray], npt.NDArray] = np.vectorize(round)
Expand Down
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/sparse/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
open_source: bool = getattr(fbgemm_gpu, "open_source", False)

if not open_source:
if torch.version.hip:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_hip")
else:
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")

torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu/codegen:index_select_ops")

suppressed_list: List[HealthCheck] = (
Expand Down

0 comments on commit e589027

Please sign in to comment.