@@ -66,20 +66,20 @@ static std::string ggml_kompute_format_name(int device) {
66
66
return " Kompute" + std::to_string (device);
67
67
}
68
68
69
- struct ggml_kompute_context {
69
+ struct ggml_backend_kompute_context {
70
70
int device;
71
71
std::string name;
72
72
std::shared_ptr<vk::DescriptorPool> pool;
73
73
74
- ggml_kompute_context (int device)
74
+ ggml_backend_kompute_context (int device)
75
75
: device(device), name(ggml_kompute_format_name(device)) {}
76
76
};
77
77
78
78
// FIXME: It would be good to consolidate the kompute manager and the kompute context into one object
79
79
// and consolidate the init functions and simplify object lifetime management. As it currently stands,
80
80
// we *have* to have the kompute manager no matter what for device discovery, but the kompute context
81
81
// is only created when a device is set and vulkan is explicitly turned on.
82
- static ggml_kompute_context *s_kompute_context = nullptr ;
82
+ static ggml_backend_kompute_context *s_kompute_context = nullptr ;
83
83
84
84
class kompute_manager {
85
85
kp::Manager *s_mgr = nullptr ;
@@ -348,7 +348,7 @@ ggml_vk_device ggml_vk_current_device() {
348
348
}
349
349
350
350
static
351
- void ggml_vk_allocate_descriptor_pool (struct ggml_kompute_context * ctx, size_t size) {
351
+ void ggml_vk_allocate_descriptor_pool (struct ggml_backend_kompute_context * ctx, size_t size) {
352
352
std::vector<vk::DescriptorPoolSize> descriptorPoolSizes = {
353
353
vk::DescriptorPoolSize (
354
354
vk::DescriptorType::eStorageBuffer,
@@ -370,7 +370,7 @@ void ggml_vk_allocate_descriptor_pool(struct ggml_kompute_context * ctx, size_t
370
370
}
371
371
372
372
static
373
- void ggml_vk_free_descriptor_pool (struct ggml_kompute_context * ctx) {
373
+ void ggml_vk_free_descriptor_pool (struct ggml_backend_kompute_context * ctx) {
374
374
if (ctx->pool ) {
375
375
komputeManager ()->device ()->destroy (
376
376
*ctx->pool ,
@@ -1412,7 +1412,7 @@ static bool ggml_vk_supports_op(const struct ggml_tensor * op) {
1412
1412
return false ;
1413
1413
}
1414
1414
1415
- static void ggml_vk_graph_compute (struct ggml_kompute_context * ctx, struct ggml_cgraph * gf) {
1415
+ static void ggml_vk_graph_compute (struct ggml_backend_kompute_context * ctx, struct ggml_cgraph * gf) {
1416
1416
const int n_seq = 8 ;
1417
1417
1418
1418
// FIXME: Figure out if we can somehow optimize the size of the pool... right now we're setting
@@ -1935,12 +1935,12 @@ ggml_backend_buffer_type_t ggml_backend_kompute_buffer_type(int device) {
1935
1935
// backend
1936
1936
1937
1937
static const char * ggml_backend_kompute_name (ggml_backend_t backend) {
1938
- auto * ctx = static_cast <ggml_kompute_context *>(backend->context );
1938
+ auto * ctx = static_cast <ggml_backend_kompute_context *>(backend->context );
1939
1939
return ctx->name .c_str ();
1940
1940
}
1941
1941
1942
1942
static void ggml_backend_kompute_free (ggml_backend_t backend) {
1943
- auto * ctx = static_cast <ggml_kompute_context *>(backend->context );
1943
+ auto * ctx = static_cast <ggml_backend_kompute_context *>(backend->context );
1944
1944
1945
1945
assert (ctx == s_kompute_context);
1946
1946
s_kompute_context = nullptr ;
@@ -1952,12 +1952,12 @@ static void ggml_backend_kompute_free(ggml_backend_t backend) {
1952
1952
}
1953
1953
1954
1954
static ggml_backend_buffer_type_t ggml_backend_kompute_get_default_buffer_type (ggml_backend_t backend) {
1955
- auto * ctx = static_cast <ggml_kompute_context *>(backend->context );
1955
+ auto * ctx = static_cast <ggml_backend_kompute_context *>(backend->context );
1956
1956
return ggml_backend_kompute_buffer_type (ctx->device );
1957
1957
}
1958
1958
1959
1959
static ggml_status ggml_backend_kompute_graph_compute (ggml_backend_t backend, struct ggml_cgraph * cgraph) {
1960
- auto * ctx = static_cast <ggml_kompute_context *>(backend->context );
1960
+ auto * ctx = static_cast <ggml_backend_kompute_context *>(backend->context );
1961
1961
ggml_vk_graph_compute (ctx, cgraph);
1962
1962
return GGML_STATUS_SUCCESS;
1963
1963
}
@@ -2002,7 +2002,7 @@ static ggml_guid_t ggml_backend_kompute_guid() {
2002
2002
2003
2003
ggml_backend_t ggml_backend_kompute_init (int device) {
2004
2004
GGML_ASSERT (s_kompute_context == nullptr );
2005
- s_kompute_context = new ggml_kompute_context (device);
2005
+ s_kompute_context = new ggml_backend_kompute_context (device);
2006
2006
2007
2007
ggml_backend_t kompute_backend = new ggml_backend {
2008
2008
/* .guid = */ ggml_backend_kompute_guid (),
0 commit comments