aboutsummaryrefslogtreecommitdiff
path: root/llama-util.h
diff options
context:
space:
mode:
Diffstat (limited to 'llama-util.h')
-rw-r--r--llama-util.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/llama-util.h b/llama-util.h
index 3cac9f6..4f8a429 100644
--- a/llama-util.h
+++ b/llama-util.h
@@ -405,13 +405,29 @@ struct llama_buffer {
llama_buffer() = default;
void resize(size_t len) {
+#ifdef GGML_USE_METAL
+ free(addr);
+ int result = posix_memalign((void **) &addr, getpagesize(), len);
+ if (result == 0) {
+ memset(addr, 0, len);
+ }
+ else {
+ addr = NULL;
+ }
+#else
delete[] addr;
addr = new uint8_t[len];
+#endif
size = len;
}
~llama_buffer() {
+#ifdef GGML_USE_METAL
+ free(addr);
+#else
delete[] addr;
+#endif
+ addr = NULL;
}
// disable copy and move