Skip to content

Commit 0d884c2

Browse files
committed
pre-commit
1 parent c0f299f commit 0d884c2

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

cuda_core/cuda/core/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@
6262
)
6363
from cuda.core._module import Kernel, ObjectCode # noqa: E402
6464
from cuda.core._program import Program, ProgramOptions # noqa: E402
65+
from cuda.core._stream import ( # noqa: E402
66+
LEGACY_DEFAULT_STREAM,
67+
PER_THREAD_DEFAULT_STREAM,
68+
Stream,
69+
StreamOptions,
70+
)
6571
from cuda.core._tensor_map import ( # noqa: E402
66-
TensorMapDescriptor,
6772
TensorMapDataType,
73+
TensorMapDescriptor,
6874
TensorMapIm2ColWideMode,
6975
TensorMapInterleave,
7076
TensorMapL2Promotion,
7177
TensorMapOOBFill,
7278
TensorMapSwizzle,
7379
)
74-
from cuda.core._stream import ( # noqa: E402
75-
LEGACY_DEFAULT_STREAM,
76-
PER_THREAD_DEFAULT_STREAM,
77-
Stream,
78-
StreamOptions,
79-
)

cuda_core/examples/tma_replace_address.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import cupy as cp
3232
import numpy as np
33-
3433
from cuda.core import (
3534
Device,
3635
LaunchConfig,

cuda_core/examples/tma_tensor_map.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import cupy as cp
2727
import numpy as np
28-
2928
from cuda.core import (
3029
Device,
3130
LaunchConfig,

cuda_core/tests/test_tensor_map.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import pytest
5-
64
import numpy as np
7-
5+
import pytest
86
from cuda.core import (
97
Device,
10-
TensorMapDescriptor,
118
TensorMapDataType,
9+
TensorMapDescriptor,
1210
TensorMapIm2ColWideMode,
1311
TensorMapInterleave,
1412
TensorMapL2Promotion,
@@ -28,14 +26,14 @@ def skip_if_no_tma(dev):
2826
pytest.skip("Device does not support TMA (requires compute capability 9.0+)")
2927

3028

31-
3229
class _DeviceArray:
3330
"""Wrap a Buffer with explicit shape via __cuda_array_interface__.
3431
3532
dev.allocate() returns a 1D byte buffer. For multi-dimensional TMA tests
3633
we need the tensor to report a proper shape/dtype so the TMA encoder sees
3734
the correct rank, dimensions, and strides.
3835
"""
36+
3937
def __init__(self, buf, shape, dtype=np.float32):
4038
self._buf = buf # prevent GC
4139
self.__cuda_array_interface__ = {
@@ -225,25 +223,30 @@ def test_invalid_data_type(self, dev, skip_if_no_tma):
225223
class TestTensorMapDtypeMapping:
226224
"""Test automatic dtype inference from numpy dtypes."""
227225

228-
@pytest.mark.parametrize("np_dtype,expected_tma_dt", [
229-
(np.uint8, TensorMapDataType.UINT8),
230-
(np.uint16, TensorMapDataType.UINT16),
231-
(np.uint32, TensorMapDataType.UINT32),
232-
(np.int32, TensorMapDataType.INT32),
233-
(np.uint64, TensorMapDataType.UINT64),
234-
(np.int64, TensorMapDataType.INT64),
235-
(np.float16, TensorMapDataType.FLOAT16),
236-
(np.float32, TensorMapDataType.FLOAT32),
237-
(np.float64, TensorMapDataType.FLOAT64),
238-
])
226+
@pytest.mark.parametrize(
227+
"np_dtype,expected_tma_dt",
228+
[
229+
(np.uint8, TensorMapDataType.UINT8),
230+
(np.uint16, TensorMapDataType.UINT16),
231+
(np.uint32, TensorMapDataType.UINT32),
232+
(np.int32, TensorMapDataType.INT32),
233+
(np.uint64, TensorMapDataType.UINT64),
234+
(np.int64, TensorMapDataType.INT64),
235+
(np.float16, TensorMapDataType.FLOAT16),
236+
(np.float32, TensorMapDataType.FLOAT32),
237+
(np.float64, TensorMapDataType.FLOAT64),
238+
],
239+
)
239240
def test_dtype_mapping(self, np_dtype, expected_tma_dt, dev, skip_if_no_tma):
240241
from cuda.core._tensor_map import _NUMPY_DTYPE_TO_TMA
242+
241243
assert _NUMPY_DTYPE_TO_TMA[np.dtype(np_dtype)] == expected_tma_dt
242244

243245
def test_bfloat16_mapping(self):
244246
try:
245-
from ml_dtypes import bfloat16
246247
from cuda.core._tensor_map import _NUMPY_DTYPE_TO_TMA
248+
from ml_dtypes import bfloat16
249+
247250
assert _NUMPY_DTYPE_TO_TMA[np.dtype(bfloat16)] == TensorMapDataType.BFLOAT16
248251
except ImportError:
249252
pytest.skip("ml_dtypes not installed")

0 commit comments

Comments
 (0)