Skip to content

Commit 67d00e7

Browse files
committed
remotingfrontend: cache some values
1 parent 1d4bbef commit 67d00e7

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

ggml/src/ggml-remotingfrontend/ggml-backend-buffer-type.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,26 @@ ggml_backend_remoting_buffer_type_get_alignment(ggml_backend_buffer_type_t buft)
4747
IMPLEMENTED_ONCE;
4848
struct virtgpu *gpu = BUFT_TO_GPU(buft);
4949

50-
return apir_buffer_type_get_alignment(gpu, buft);
50+
static size_t align = 0;
51+
52+
if (align == 0) {
53+
align = apir_buffer_type_get_alignment(gpu, buft);
54+
}
55+
56+
return align;
5157
}
5258

5359
static size_t
5460
ggml_backend_remoting_buffer_type_get_max_size(ggml_backend_buffer_type_t buft) {
5561
IMPLEMENTED_ONCE;
5662
struct virtgpu *gpu = BUFT_TO_GPU(buft);
5763

58-
return apir_buffer_type_get_max_size(gpu, buft);
64+
static size_t max_size = 0;
65+
if (max_size == 0) {
66+
max_size = apir_buffer_type_get_max_size(gpu, buft);
67+
}
68+
69+
return max_size;
5970
}
6071

6172
static bool

ggml/src/ggml-remotingfrontend/ggml-backend-device.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ ggml_backend_remoting_device_get_type(ggml_backend_dev_t dev) {
2323
IMPLEMENTED_ONCE;
2424
struct virtgpu *gpu = DEV_TO_GPU(dev);
2525

26-
return (enum ggml_backend_dev_type) apir_device_get_type(gpu);
26+
static enum ggml_backend_dev_type type;
27+
static bool has_type = false;
28+
if (!has_type) {
29+
has_type = true;
30+
type = (enum ggml_backend_dev_type) apir_device_get_type(gpu);
31+
}
32+
33+
return type;
2734
}
2835

2936
static void

0 commit comments

Comments
 (0)