Skip to content

Commit

Permalink
Fix sparse ops tests (#2296)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2296

- Fix sparse ops tests to pass again

Reviewed By: spcyppt

Differential Revision: D53244522

fbshipit-source-id: aa6d5365dd34ba0a61b3d65cad1bbd3e717b187e
  • Loading branch information
q10 authored and facebook-github-bot committed Jan 31, 2024
1 parent fdc8314 commit 2a7b3ab
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 63 deletions.
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/sparse/block_bucketize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@
import unittest
from typing import Optional, Type

import fbgemm_gpu
import hypothesis.strategies as st
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
11 changes: 11 additions & 0 deletions fbgemm_gpu/test/sparse/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
from torch._utils_internal import get_file_path_2
from torch.testing._internal.optests import generate_opcheck_tests

# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
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/codegen:index_select_ops")

suppressed_list: List[HealthCheck] = (
# pyre-fixme[16]: Module `HealthCheck` has no attribute `differing_executors`.
Expand Down
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/sparse/cumsum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@

import unittest

import fbgemm_gpu
import hypothesis.strategies as st
import numpy as np
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/sparse/histogram_binning_calibration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@
import random
import unittest

import fbgemm_gpu
import hypothesis.strategies as st
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
8 changes: 1 addition & 7 deletions fbgemm_gpu/test/sparse/index_select_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@
import unittest
from typing import Callable, Dict, List

import fbgemm_gpu

import hypothesis.strategies as st
import numpy as np
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
8 changes: 1 addition & 7 deletions fbgemm_gpu/test/sparse/misc_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@
import unittest
from typing import Type, Union

import fbgemm_gpu

import hypothesis.strategies as st
import numpy as np
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
6 changes: 1 addition & 5 deletions fbgemm_gpu/test/sparse/pack_segments_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@
import unittest
from typing import Callable, Optional

import fbgemm_gpu
import hypothesis.strategies as st
import numpy as np
import torch
from hypothesis import given, settings

from .common import extend_test_class

# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/sparse/permute_embeddings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
import unittest
from typing import Any, Callable, Tuple

import fbgemm_gpu
import hypothesis.strategies as st
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class, permute_indices_ref_


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source, permute_indices_ref_

if open_source:
# pyre-ignore[21]
Expand Down
12 changes: 6 additions & 6 deletions fbgemm_gpu/test/sparse/permute_indices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
from itertools import accumulate
from typing import List, Optional

import fbgemm_gpu
import hypothesis.strategies as st
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class, permute_indices_ref_, permute_scripted


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import (
extend_test_class,
open_source,
permute_indices_ref_,
permute_scripted,
)

if open_source:
# pyre-ignore[21]
Expand Down
7 changes: 1 addition & 6 deletions fbgemm_gpu/test/sparse/permute_sparse_features_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
import unittest
from typing import cast, Optional, Tuple

import fbgemm_gpu
import hypothesis.strategies as st
import torch
from hypothesis import given, settings

from .common import extend_test_class, permute_indices_ref_


# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source, permute_indices_ref_

if open_source:
# pyre-ignore[21]
Expand Down
6 changes: 1 addition & 5 deletions fbgemm_gpu/test/sparse/reorder_batched_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
import random
import unittest

import fbgemm_gpu
import hypothesis.strategies as st
import torch
from hypothesis import given, settings, Verbosity

from .common import extend_test_class

# pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`.
open_source: bool = getattr(fbgemm_gpu, "open_source", False)
from .common import extend_test_class, open_source

if open_source:
# pyre-ignore[21]
Expand Down
4 changes: 1 addition & 3 deletions fbgemm_gpu/test/uvm/copy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
from fbgemm_gpu.test.test_utils import gpu_available, gpu_unavailable, skipIfRocm

if gpu_available:
# pyre-ignore[21]
from fbgemm_gpu.uvm import cudaMemAdvise, cudaMemoryAdvise, cudaMemPrefetchAsync

import fbgemm_gpu.uvm

MAX_EXAMPLES = 40

Expand Down

0 comments on commit 2a7b3ab

Please sign in to comment.