Skip to content

Commit 5e5c5e7

Browse files
committed
cuda : fix HIP build
1 parent 7a8c050 commit 5e5c5e7

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

ggml-common.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ typedef uint32_t ggml_half2;
1212
#elif defined(GGML_COMMON_DECL_METAL)
1313
#include <metal_stdlib>
1414

15-
typedef half ggml_half;
16-
typedef half2 ggml_half2;
15+
typedef half ggml_half;
16+
typedef half2 ggml_half2;
1717

1818
#define GGML_COMMON_AGGR
1919

@@ -22,8 +22,18 @@ typedef half2 ggml_half2;
2222
#include <cuda_fp16.h>
2323
#include <cstdint>
2424

25-
typedef half ggml_half;
26-
typedef half2 ggml_half2;
25+
typedef half ggml_half;
26+
typedef half2 ggml_half2;
27+
28+
#define GGML_COMMON_AGGR data
29+
30+
#define GGML_COMMON_DECL
31+
#elif defined(GGML_COMMON_DECL_HIP)
32+
#include <hip/hip_fp16.h>
33+
#include <cstdint>
34+
35+
typedef half ggml_half;
36+
typedef half2 ggml_half2;
2737

2838
#define GGML_COMMON_AGGR data
2939

@@ -373,7 +383,7 @@ static_assert(sizeof(block_iq4_xs) == sizeof(ggml_half) + sizeof(uint16_t) + QK_
373383
#define GGML_TABLE_END() };
374384

375385
#define GGML_COMMON_IMPL
376-
#elif defined(GGML_COMMON_IMPL_CUDA)
386+
#elif defined(GGML_COMMON_IMPL_CUDA) || defined(GGML_COMMON_IMPL_HIP)
377387
#include <cstdint>
378388

379389
#define GGML_TABLE_BEGIN(type, name, size) static const __device__ __constant__ type name[size] = {

ggml-cuda.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
#include "ggml.h"
33
#include "ggml-backend-impl.h"
44

5+
#if defined(GGML_USE_HIPBLAS)
6+
#define GGML_COMMON_DECL_HIP
7+
#define GGML_COMMON_IMPL_HIP
8+
#else
59
#define GGML_COMMON_DECL_CUDA
610
#define GGML_COMMON_IMPL_CUDA
11+
#endif
712
#include "ggml-common.h"
813

914
#include <algorithm>

0 commit comments

Comments
 (0)