aboutsummaryrefslogtreecommitdiff
path: root/llama_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'llama_util.h')
-rwxr-xr-xllama_util.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/llama_util.h b/llama_util.h
index acb207e..6e66d12 100755
--- a/llama_util.h
+++ b/llama_util.h
@@ -405,4 +405,30 @@ struct llama_buffer {
delete[] addr;
}
};
+
+#ifdef GGML_USE_CUBLAS
+#include "ggml-cuda.h"
+struct llama_ctx_buffer {
+ uint8_t * addr = NULL;
+ size_t size = 0;
+
+ void resize(size_t size) {
+ if (addr) {
+ ggml_cuda_host_free(addr);
+ }
+ addr = (uint8_t *) ggml_cuda_host_malloc(size);
+ this->size = size;
+ }
+
+ ~llama_ctx_buffer() {
+ if (addr) {
+ ggml_cuda_host_free(addr);
+ }
+ }
+};
+#else
+typedef llama_buffer llama_ctx_buffer;
+#endif
+
+
#endif