Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions test/ir/inference/test_float8_gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import re
import shutil
import unittest

import numpy as np
from op_test import get_cuda_version

import paddle
from paddle.base import core
Expand All @@ -28,18 +27,6 @@
E5M2_MAX_POS = 57344.0


def get_cuda_version():
result = os.popen("nvcc --version").read()
regex = r'release (\S+),'
match = re.search(regex, result)
if match:
num = str(match.group(1))
integer, decimal = num.split('.')
return int(integer) * 1000 + int(float(decimal) * 10)
else:
return -1


def check_fp8_support() -> bool:
"""Return if fp8 support is available"""
gpu_arch = (
Expand Down
15 changes: 1 addition & 14 deletions test/ir/pir/fused_pass/test_fused_flash_attn_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import re
import unittest

import numpy as np
from op_test import get_cuda_version
from pass_test import PassTest

import paddle
Expand All @@ -26,18 +25,6 @@
paddle.enable_static()


def get_cuda_version():
result = os.popen("nvcc --version").read()
regex = r'release (\S+),'
match = re.search(regex, result)
if match:
num = str(match.group(1))
integer, decimal = num.split('.')
return int(integer) * 1000 + int(float(decimal) * 10)
else:
return -1


is_sm_supported = (
core.is_compiled_with_cuda()
and paddle.device.cuda.get_device_capability()[0] >= 8
Expand Down
14 changes: 0 additions & 14 deletions test/ir/pir/fused_pass/test_fused_weight_only_linear_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import re
import unittest

import numpy as np
Expand All @@ -26,18 +24,6 @@
np.random.seed(2013)


def get_cuda_version():
result = os.popen("nvcc --version").read()
regex = r'release (\S+),'
match = re.search(regex, result)
if match:
num = str(match.group(1))
integer, decimal = num.split('.')
return int(integer) * 1000 + int(float(decimal) * 10)
else:
return -1


@unittest.skipIf(
not core.is_compiled_with_cuda(),
"weight_only_linear requires compiled with CUDA",
Expand Down
15 changes: 1 addition & 14 deletions test/ir/pir/test_convert_mea_2_fa_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import re
import unittest

import numpy as np
from fused_pass.pass_test import PassTest
from op_test import get_cuda_version

import paddle
from paddle.base import core
Expand All @@ -28,18 +27,6 @@
paddle.enable_static()


def get_cuda_version():
result = os.popen("nvcc --version").read()
regex = r'release (\S+),'
match = re.search(regex, result)
if match:
num = str(match.group(1))
integer, decimal = num.split('.')
return int(integer) * 1000 + int(float(decimal) * 10)
else:
return -1


is_sm8x = (
core.is_compiled_with_cuda()
and paddle.device.cuda.get_device_capability()[0] == 8
Expand Down
3 changes: 1 addition & 2 deletions test/legacy_test/test_bfloat16_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import numpy as np
from op_test import is_custom_device
from test_sparse_attention_op import get_cuda_version

import paddle
import paddle.nn.functional as F
Expand Down Expand Up @@ -61,7 +60,7 @@ def gen_random(self):
def test_main(self):
if (
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000
or paddle.is_compiled_with_rocm()
):
return

Expand Down
3 changes: 1 addition & 2 deletions test/legacy_test/test_fused_gate_attention_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
get_device_place,
is_custom_device,
)
from test_sparse_attention_op import get_cuda_version

import paddle
import paddle.incubate.nn.functional as F
Expand Down Expand Up @@ -411,7 +410,7 @@ def config(self):

@unittest.skipIf(
not core.is_compiled_with_cuda()
or get_cuda_version() < 11000
or paddle.is_compiled_with_rocm()
or paddle.device.cuda.get_device_capability()[0] < 8,
"core is not compiled with CUDA and cuda version need larger than or equal to 11.3",
)
Expand Down
3 changes: 1 addition & 2 deletions test/legacy_test/test_matmul_int8_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import unittest

import numpy as np
from op_test import is_custom_device
from test_sparse_attention_op import get_cuda_version
from op_test import get_cuda_version, is_custom_device

import paddle
from paddle.base import core
Expand Down
24 changes: 12 additions & 12 deletions test/legacy_test/test_sparse_matmul_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def check_result(self, x_shape, y_shape, format):

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_matmul_2d(self):
self.check_result([16, 12], [12, 10], 'coo')
Expand Down Expand Up @@ -125,17 +125,17 @@ def check_result(self, x_shape, y_shape, format):

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_matmul_2d(self):
self.check_result([16, 12], [12, 10], 'coo')
self.check_result([16, 12], [12, 10], 'csr')

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_matmul_3d(self):
self.check_result([8, 16, 12], [8, 12, 10], 'coo')
Expand Down Expand Up @@ -206,17 +206,17 @@ def check_result(self, x_shape, y_shape, format):

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_matmul_2d(self):
self.check_result([16, 12], [12, 10], 'coo')
self.check_result([16, 12], [12, 10], 'csr')

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_matmul_3d(self):
self.check_result([8, 16, 12], [8, 12, 10], 'coo')
Expand Down Expand Up @@ -367,8 +367,8 @@ def check_result(self, x_shape, y_shape):

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_matmul_2d(self):
if in_pir_mode():
Expand Down
18 changes: 2 additions & 16 deletions test/legacy_test/test_sparse_pca_lowrank.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import random
import re
import unittest

import numpy as np
Expand All @@ -22,18 +20,6 @@
import paddle


def get_cuda_version():
result = os.popen("nvcc --version").read()
regex = r'release (\S+),'
match = re.search(regex, result)
if match:
num = str(match.group(1))
integer, decimal = num.split('.')
return int(integer) * 1000 + int(float(decimal) * 10)
else:
return -1


class TestSparsePcaLowrankAPI(unittest.TestCase):
def transpose(self, x):
shape = x.shape
Expand Down Expand Up @@ -91,8 +77,8 @@ def run_subtest(self, guess_rank, matrix_size, batches, pca, **options):

@unittest.skipIf(
not (paddle.is_compiled_with_cuda() or is_custom_device())
or get_cuda_version() < 11000,
"only support cuda>=11.0",
or paddle.is_compiled_with_rocm(),
"only support cuda",
)
def test_sparse(self):
pca_lowrank = paddle.sparse.pca_lowrank
Expand Down
Loading