Skip to content

Commit

Permalink
[CUDNN] Format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yudi Sun committed Jun 27, 2024
1 parent 5d5d8a6 commit 2f8fdaa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions python/hidet/cuda/cudnn/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def benchmark_cudnn_conv2d_gemm(dtype, compute_type, n, c, h, w, k, p, q, r, s,
print("-------------------------------------------------")



def benchmark_torch_conv2d(dtype, compute_type, n, c, h, w, k, p, q, r, s, padding, stride, dilations):
# Native PyTorch Eager-mode Execution
data = np.array(np.random.randn(n, c, h, w)).astype(dtype)
Expand Down Expand Up @@ -129,7 +128,7 @@ def benchmark_torch_conv2d(dtype, compute_type, n, c, h, w, k, p, q, r, s, paddi

def benchmark_hidet_conv2d(dtype, compute_type, n, c, h, w, k, p, q, r, s, padding, stride, dilations):
# Uses optimized Hidet Graph implementation
tx = tw = ty = dtype
tx = tw = dtype
pad_dim1, pad_dim2 = padding
str_dim1, str_dim2 = stride
dil_dim1, dil_dim2 = dilations
Expand Down
1 change: 0 additions & 1 deletion python/hidet/cuda/cudnn/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,3 @@ def conv2d_gemm(
dil_dim1,
dil_dim2,
)

26 changes: 14 additions & 12 deletions tests/cuda/test_cudnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
[
[1, 3, 32, 32, 12, 30, 30, 3, 3, [0, 0], [1, 1], [1, 1]], # kernel 3,
[2, 3, 32, 32, 12, 11, 6, 7, 7, [1, 2], [2, 3], [2, 3]], # kernel 7, batch size 2
[1, 3, 224, 224, 64, 112, 112, 7, 7, [3, 3], [2, 2], [1, 1]], # resnet layer 1
[1, 64, 56, 56, 128, 56, 56, 1, 1, [0, 0], [1, 1], [1, 1]], # resnet layer 2 - kernel size 1
[1, 3, 224, 224, 64, 112, 112, 7, 7, [3, 3], [2, 2], [1, 1]], # resnet layer 1
[1, 64, 56, 56, 128, 56, 56, 1, 1, [0, 0], [1, 1], [1, 1]], # resnet layer 2 - kernel size 1
],
)
@pytest.mark.parametrize(
'dtype, compute_type, tol',
[(hidet.float16, cudnnDataType.CUDNN_DATA_HALF, 1e-2),
(hidet.float32, cudnnDataType.CUDNN_DATA_FLOAT, 1e-5),
(hidet.float64, cudnnDataType.CUDNN_DATA_DOUBLE, 1e-8),
]
[
(hidet.float16, cudnnDataType.CUDNN_DATA_HALF, 1e-2),
(hidet.float32, cudnnDataType.CUDNN_DATA_FLOAT, 1e-5),
(hidet.float64, cudnnDataType.CUDNN_DATA_DOUBLE, 1e-8),
],
)
def test_cudnn_conv2d(n, c, h, w, k, p, q, r, s, dtype, compute_type, padding, stride, dilations, tol):
tx = tw = ty = dtype
Expand Down Expand Up @@ -78,16 +79,17 @@ def test_cudnn_conv2d(n, c, h, w, k, p, q, r, s, dtype, compute_type, padding, s
[
[1, 3, 32, 32, 12, 30, 30, 3, 3, [0, 0], [1, 1], [1, 1]], # kernel 3,
[2, 3, 32, 32, 12, 11, 6, 7, 7, [1, 2], [2, 3], [2, 3]], # kernel 7, batch size 2
[1, 3, 224, 224, 64, 112, 112, 7, 7, [3, 3], [2, 2], [1, 1]], # resnet layer 1
[1, 64, 56, 56, 128, 56, 56, 1, 1, [0, 0], [1, 1], [1, 1]], # resnet layer 2 - kernel size 1
[1, 3, 224, 224, 64, 112, 112, 7, 7, [3, 3], [2, 2], [1, 1]], # resnet layer 1
[1, 64, 56, 56, 128, 56, 56, 1, 1, [0, 0], [1, 1], [1, 1]], # resnet layer 2 - kernel size 1
],
)
@pytest.mark.parametrize(
'dtype, compute_type, tol',
[(hidet.float16, cudnnDataType.CUDNN_DATA_HALF, 1e-2),
(hidet.float32, cudnnDataType.CUDNN_DATA_FLOAT, 1e-5),
(hidet.float64, cudnnDataType.CUDNN_DATA_DOUBLE, 1e-8),
]
[
(hidet.float16, cudnnDataType.CUDNN_DATA_HALF, 1e-2),
(hidet.float32, cudnnDataType.CUDNN_DATA_FLOAT, 1e-5),
(hidet.float64, cudnnDataType.CUDNN_DATA_DOUBLE, 1e-8),
],
)
def test_cudnn_conv2d_gemm(n, c, h, w, k, p, q, r, s, dtype, compute_type, padding, stride, dilations, tol):
tx = tw = ty = dtype
Expand Down

0 comments on commit 2f8fdaa

Please sign in to comment.