ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ggma_generate.h File Reference

This file defines the GGMA text generation API. More...

#include "ggma_types.h"

Go to the source code of this file.

Functions

GGMA_STATUS ggma_generate (struct ggma_context *context, ggma_token *tokens, size_t n_tokens, size_t n_tokens_max, size_t *n_tokens_out)
 Generates a sequence of tokens based on the provided prompt tokens.
 

Detailed Description

This file defines the GGMA text generation API.

Definition in file ggma_generate.h.

Function Documentation

◆ ggma_generate()

GGMA_STATUS ggma_generate ( struct ggma_context context,
ggma_token tokens,
size_t  n_tokens,
size_t  n_tokens_max,
size_t *  n_tokens_out 
)

Generates a sequence of tokens based on the provided prompt tokens.

This function performs the core inference step, taking an initial sequence of prompt tokens and generating new tokens autoregressively.

Parameters
[in]contextThe GGMA context to use for generation.
[in,out]tokensAn array of input prompt tokens. The generated tokens will be placed in this buffer
[in]n_tokensThe number of tokens in the input tokens array. This also often specifies the maximum number of tokens to generate.
[in]n_tokens_maxThe maximum number of tokens that the tokens buffer can hold.
[out]n_tokens_outA pointer to a variable that will receive the number of element in the tokens after generation
Returns
GGMA_STATUS_NO_ERROR on success, or an appropriate error code on failure.

Definition at line 22 of file ggma_generate.cc.

24{
26 return reinterpret_cast<ggma::Context *>(context)->generate(tokens, n_tokens, n_tokens_max,
27 n_tokens_out);
28}
#define GGMA_RETURN_ERROR_IF_NULL(p)
Definition Macro.h:26

References GGMA_RETURN_ERROR_IF_NULL.