Download include/ling3/model_package.h from Sariel00/Ling-3.0-tiny-RKNN: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/Sariel00/Ling-3.0-tiny-RKNN/resolve/main/include/ling3/model_package.h
- Command line
-
hf download hf://Sariel00/Ling-3.0-tiny-RKNN/include/ling3/model_package.h
-
curl -L -o model_package.h https://huggingface.co/Sariel00/Ling-3.0-tiny-RKNN/resolve/main/include/ling3/model_package.h
1.88 kB
| namespace ling3 { | |
| struct TensorView { | |
| std::string_view name; | |
| const TensorEntry * entry = nullptr; | |
| const std::byte * data = nullptr; | |
| const std::byte * aux = nullptr; | |
| }; | |
| class ModelPackage { | |
| public: | |
| explicit ModelPackage(const std::filesystem::path & path); | |
| ~ModelPackage(); | |
| ModelPackage(const ModelPackage &) = delete; | |
| ModelPackage & operator=(const ModelPackage &) = delete; | |
| const PackageHeader & header() const noexcept { return *header_; } | |
| const std::vector<TensorView> & tensors() const noexcept { return tensors_; } | |
| const TensorView & tensor(std::string_view name) const; | |
| std::size_t mapped_bytes() const noexcept { return mapped_bytes_; } | |
| // After a consumer has synchronously copied a linear weight, discard only | |
| // whole source pages inside that tensor. The read-only file remains valid. | |
| void DiscardCopiedLinearWeight(const TensorView & weight) const; | |
| std::size_t discarded_weight_bytes() const noexcept { return discarded_weight_bytes_; } | |
| std::size_t cache_advice_failures() const noexcept { return cache_advice_failures_; } | |
| std::size_t resident_linear_weight_bytes() const; | |
| private: | |
| void Reset() noexcept; | |
| int fd_ = -1; | |
| const std::byte * mapping_ = nullptr; | |
| std::size_t mapped_bytes_ = 0; | |
| const PackageHeader * header_ = nullptr; | |
| std::vector<TensorView> tensors_; | |
| std::unordered_map<std::string_view, std::size_t> tensor_index_; | |
| mutable std::atomic_size_t discarded_weight_bytes_ {0}; | |
| mutable std::atomic_size_t cache_advice_failures_ {0}; | |
| }; | |
| void ValidateLing3Tiny(const PackageHeader & header); | |
| std::uint32_t Crc32(const std::byte * data, std::size_t bytes); | |
| } // namespace ling3 | |