ggml-alloc.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * llama.cpp - git 465219b9143ac01db0990bbcb0a081ef72ec2008
  3. *
  4. * MIT License
  5. *
  6. * Copyright (c) 2023 Georgi Gerganov
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all
  16. * copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE.
  25. */
  26. #pragma once
  27. #include "ggml.h"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. struct ggml_backend_buffer;
  32. GGML_API struct ggml_allocr * ggml_allocr_new(void * data, size_t size, size_t alignment);
  33. GGML_API struct ggml_allocr * ggml_allocr_new_measure(size_t alignment);
  34. GGML_API struct ggml_allocr * ggml_allocr_new_from_buffer(struct ggml_backend_buffer * buffer);
  35. // tell the allocator to parse nodes following the order described in the list
  36. // you should call this if your graph are optimized to execute out-of-order
  37. GGML_API void ggml_allocr_set_parse_seq(struct ggml_allocr * alloc, const int * list, int n);
  38. GGML_API void ggml_allocr_free (struct ggml_allocr * alloc);
  39. GGML_API bool ggml_allocr_is_measure (struct ggml_allocr * alloc);
  40. GGML_API void ggml_allocr_reset (struct ggml_allocr * alloc);
  41. GGML_API void ggml_allocr_alloc (struct ggml_allocr * alloc, struct ggml_tensor * tensor);
  42. GGML_API size_t ggml_allocr_alloc_graph(struct ggml_allocr * alloc, struct ggml_cgraph * graph);
  43. GGML_API size_t ggml_allocr_max_size (struct ggml_allocr * alloc);
  44. GGML_API size_t ggml_allocr_alloc_graph_n(
  45. struct ggml_allocr * alloc,
  46. struct ggml_cgraph ** graphs, int n_graphs,
  47. struct ggml_tensor *** inputs, struct ggml_tensor *** outputs);
  48. #ifdef __cplusplus
  49. }
  50. #endif