#pragma once #include #include #include #include #include #include #include namespace engine::io { struct SafeTensorInfo { std::string name; std::string dtype; std::vector shape; size_t data_begin = 0; size_t data_end = 0; }; struct SafeTensorIndex { std::filesystem::path source_path; std::unordered_map metadata; std::unordered_map tensors; size_t header_bytes = 0; }; struct SafeTensorWriteEntry { std::string name; std::string dtype; std::vector shape; std::vector data; }; SafeTensorIndex load_safetensors_index(const std::filesystem::path & path); // The bytes of a safetensors file; metadata becomes the string map `__metadata__`. std::vector encode_safetensors( const std::vector & entries, const std::vector> & metadata = {}); void write_safetensors_file( const std::filesystem::path & path, const std::vector & entries); } // namespace engine::io