MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / loadBytesFromFile

Function loadBytesFromFile

plugins/wasi_nn/MLX/model/utils.cpp:63–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63std::string loadBytesFromFile(const std::string &Path,
64 const Host::WASI::Environ *Env) {
65 WasmEdge::FStream::IFStream Fs(Path, Env);
66 if (Fs.fail()) {
67 spdlog::error("[WASI-NN] MLX backend: Cannot open {}."sv, Path);
68 return "";
69 }
70 std::string Data;
71 Fs.seekg(0, std::ios::end);
72 const size_t Size = static_cast<size_t>(Fs.tellg());
73 Fs.seekg(0, std::ios::beg);
74 Data.resize(Size);
75 Fs.read(Data.data(), Size);
76 return Data;
77}
78
79} // namespace WasmEdge::Host::WASINN::MLX

Callers 1

loadFunction · 0.85

Calls 6

tellgMethod · 0.80
resizeMethod · 0.80
errorFunction · 0.50
failMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected