MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / build

Method build

src/framework/sampling/decode_modules.cpp:43–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43engine::core::TensorValue GreedyDecodeModule::build(engine::core::ModuleBuildContext & ctx, const engine::core::TensorValue & logits) const {
44 if (ctx.ggml == nullptr) {
45 throw std::runtime_error("ModuleBuildContext.ggml is null");
46 }
47 engine::core::validate_rank_between(logits, 3, 3, "logits");
48
49 auto flat = engine::core::reshape_tensor(
50 ctx,
51 engine::core::ensure_backend_addressable_layout(ctx, logits),
52 engine::core::TensorShape::from_dims({logits.shape.num_elements() / logits.shape.last_dim(), logits.shape.last_dim()}));
53 auto argmax = engine::core::wrap_tensor(
54 ggml_argmax(ctx.ggml, flat.tensor),
55 engine::core::TensorShape::from_dims({flat.shape.dims[0]}),
56 GGML_TYPE_I32);
57 return engine::core::reshape_tensor(ctx, argmax, engine::core::TensorShape::from_dims({logits.shape.dims[0], logits.shape.dims[1]}));
58}
59
60const engine::core::ModuleSchema & GreedyDecodeModule::static_schema() noexcept {
61 return kGreedyDecodeSchema;

Callers

nothing calls this directly

Calls 9

validate_rank_betweenFunction · 0.85
reshape_tensorFunction · 0.85
wrap_tensorFunction · 0.85
ggml_argmaxFunction · 0.85
ggml_scale_biasFunction · 0.85
ggml_stepFunction · 0.85
num_elementsMethod · 0.80
last_dimMethod · 0.80

Tested by

no test coverage detected