Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion examples/models/llama/runner/static_attention_io_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,9 @@ class StaticAttentionIOManager {
size_t prefill(
executorch::runtime::Span<TokenT> tokens,
executorch::runtime::Span<TokenT> input_buffer,
executorch::runtime::Method& method) {
executorch::runtime::Method& method,
std::function<void(executorch::runtime::Span<const float>)>
logits_callback = nullptr) {
ET_LOG(Info, "Prefilling at position %zu", input_pos_);
size_t input_len = input_buffer.size();
auto& masks = get_mask(input_buffer.size());
Expand All @@ -610,6 +612,13 @@ class StaticAttentionIOManager {
config_.k_cache_output_indices,
config_.v_cache_output_indices,
batch_len);
if (logits_callback) {
auto logits_tensor = method.get_output(0).toTensor();
auto* logits = logits_tensor.const_data_ptr<float>();
logits_callback(executorch::runtime::Span(
logits,
logits + batch_len * logits_tensor.size(logits_tensor.dim() - 1)));
}
}
return batch_len - 1;
}
Expand Down
Loading