/*! * Copyright (c) 2023-2025 by Contributors * \file support/load_bytes_from_file.h * \brief Utility methods to load from files. */ #ifndef MLC_LLM_SUPPORT_LOAD_BYTES_FROM_FILE_H_ #define MLC_LLM_SUPPORT_LOAD_BYTES_FROM_FILE_H_ #include #include #include namespace mlc { namespace llm { inline std::string LoadBytesFromFile(const std::string& path) { std::ifstream fs(path, std::ios::in | std::ios::binary); TVM_FFI_ICHECK(!fs.fail()) << "Cannot open " << path; std::string data; fs.seekg(0, std::ios::end); size_t size = static_cast(fs.tellg()); fs.seekg(0, std::ios::beg); data.resize(size); fs.read(data.data(), size); return data; } } // namespace llm } // namespace mlc #endif // MLC_LLM_SUPPORT_LOAD_BYTES_FROM_FILE_H_