ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / src / ggml-virtgpu / backend / shared / apir_cs_rpc.h
| 1 | #pragma once |
| 2 | |
| 3 | // clang-format off |
| 4 | #include "ggml.h" |
| 5 | #include "ggml-backend-impl.h" |
| 6 | |
| 7 | #include <unordered_map> |
| 8 | #include <unordered_set> |
| 9 | #include <vector> |
| 10 | #include <cstdint> |
| 11 | // clang-format on |
| 12 | |
| 13 | // ggml_tensor is serialized into apir_rpc_tensor |
| 14 | struct apir_rpc_tensor { |
| 15 | uint64_t id; |
| 16 | uint32_t type; |
| 17 | uint64_t buffer; |
| 18 | uint32_t ne[GGML_MAX_DIMS]; |
| 19 | uint32_t nb[GGML_MAX_DIMS]; |
| 20 | uint32_t op; |
| 21 | int32_t op_params[GGML_MAX_OP_PARAMS / sizeof(int32_t)]; |
| 22 | int32_t flags; |
| 23 | uint64_t src[GGML_MAX_SRC]; |
| 24 | uint64_t view_src; |
| 25 | uint64_t view_offs; |
| 26 | uint64_t data; |
| 27 | char name[GGML_MAX_NAME]; |
| 28 | |
| 29 | char padding[4]; |
| 30 | }; |
| 31 | |
| 32 | /* frontend */ |
| 33 | |
| 34 | apir_rpc_tensor apir_serialize_tensor(const ggml_tensor * tensor); |
| 35 | |
| 36 | void apir_serialize_graph(const ggml_cgraph * cgraph, std::vector<uint8_t> & output); |
| 37 | |
| 38 | /* backend */ |
| 39 | |
| 40 | void apir_track_backend_buffer(ggml_backend_buffer_t buffer); |
| 41 | bool apir_untrack_backend_buffer(ggml_backend_buffer_t buffer); |
| 42 | std::unordered_set<ggml_backend_buffer_t> apir_get_track_backend_buffers(); |
| 43 | |
| 44 | void apir_add_tensor(ggml_tensor * tensor, |
| 45 | std::vector<apir_rpc_tensor> & tensors, |
| 46 | std::unordered_set<ggml_tensor *> & visited); |
| 47 | |
| 48 | ggml_tensor * apir_deserialize_tensor(ggml_context * ctx, const apir_rpc_tensor * tensor); |
| 49 | |
| 50 | ggml_tensor * apir_create_node(uint64_t id, |
| 51 | ggml_context * ctx, |
| 52 | const std::unordered_map<uint64_t, const apir_rpc_tensor *> & tensor_ptrs, |
| 53 | std::unordered_map<uint64_t, ggml_tensor *> & tensor_map); |
| 54 | |
| 55 | ggml_cgraph * apir_deserialize_graph(uint32_t n_nodes, |
| 56 | uint32_t n_tensors, |
| 57 | const apir_rpc_tensor * tensors, |
| 58 | const uint64_t * nodes); |