Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
llama-mmap.h68 linesDownload Raw Back to src
1#pragma once2 3#include <memory>4#include <vector>5 6struct llama_file;7struct llama_mmap;8struct llama_mlock;9 10using llama_files  = std::vector<std::unique_ptr<llama_file>>;11using llama_mmaps  = std::vector<std::unique_ptr<llama_mmap>>;12using llama_mlocks = std::vector<std::unique_ptr<llama_mlock>>;13 14struct llama_file {15    llama_file(const char * fname, const char * mode);16    ~llama_file();17 18    size_t tell() const;19    size_t size() const;20 21    int file_id() const; // fileno overload22 23    void seek(size_t offset, int whence) const;24 25    void read_raw(void * ptr, size_t len) const;26    uint32_t read_u32() const;27 28    void write_raw(const void * ptr, size_t len) const;29    void write_u32(uint32_t val) const;30 31private:32    struct impl;33    std::unique_ptr<impl> pimpl;34};35 36struct llama_mmap {37    llama_mmap(const llama_mmap &) = delete;38    llama_mmap(struct llama_file * file, size_t prefetch = (size_t) -1, bool numa = false);39    ~llama_mmap();40 41    size_t size() const;42    void * addr() const;43 44    void unmap_fragment(size_t first, size_t last);45 46    static const bool SUPPORTED;47 48private:49    struct impl;50    std::unique_ptr<impl> pimpl;51};52 53struct llama_mlock {54    llama_mlock();55    ~llama_mlock();56 57    void init(void * ptr);58    void grow_to(size_t target_size);59 60    static const bool SUPPORTED;61 62private:63    struct impl;64    std::unique_ptr<impl> pimpl;65};66 67size_t llama_path_max();68