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

Function getOutput

plugins/wasi_nn/wasinn_bitnet.cpp:2184–2210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2182}
2183
2184Expect<ErrNo> getOutput(WasiNNEnvironment &Env, uint32_t ContextId,
2185 uint32_t Index, Span<uint8_t> OutBuffer,
2186 uint32_t &BytesWritten) noexcept {
2187 auto &CxtRef = Env.NNContext[ContextId].get<Context>();
2188 auto &GraphRef = Env.NNGraph[CxtRef.GraphId].get<Graph>();
2189 LOG_DEBUG(GraphRef.EnableDebugLog, "getOutput: with Index {}"sv, Index)
2190
2191 // Handle Metadata Output at Index 1
2192 if (Index == 1) {
2193 const std::string Metadata = buildOutputMetadata(CxtRef);
2194 const size_t BytesToCopy =
2195 std::min(static_cast<size_t>(OutBuffer.size()), Metadata.length());
2196 std::copy_n(Metadata.data(), BytesToCopy, OutBuffer.data());
2197 BytesWritten = static_cast<uint32_t>(Metadata.length());
2198
2199 LOG_DEBUG(GraphRef.EnableDebugLog, "getOutput: Metadata (Index 1)...Done"sv)
2200 return ErrNo::Success;
2201 }
2202
2203 const size_t BytesToCopy = std::min(static_cast<size_t>(OutBuffer.size()),
2204 CxtRef.LlamaOutputs.size());
2205 std::copy_n(CxtRef.LlamaOutputs.data(), BytesToCopy, OutBuffer.data());
2206 BytesWritten = CxtRef.LlamaOutputs.size();
2207
2208 LOG_DEBUG(GraphRef.EnableDebugLog, "getOutput: Text (Index 0)...Done"sv)
2209 return ErrNo::Success;
2210}
2211
2212Expect<ErrNo> compute(WasiNNEnvironment &Env, uint32_t ContextId) noexcept {
2213 auto &CxtRef = Env.NNContext[ContextId].get<Context>();

Callers

nothing calls this directly

Calls 4

buildOutputMetadataFunction · 0.70
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected