|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * @file ggma_context.h |
| 19 | + * @brief This file defines the GGMA context management API. |
| 20 | + */ |
| 21 | +#ifndef __GGMA_GGMA_CONTEXT_H__ |
| 22 | +#define __GGMA_GGMA_CONTEXT_H__ |
| 23 | + |
| 24 | +#include "ggma_types.h" |
| 25 | + |
| 26 | +#ifdef __cplusplus |
| 27 | +extern "C" { |
| 28 | +#endif |
| 29 | + |
| 30 | +/** |
| 31 | + * @brief Opaque handle to a GGMA inference context. |
| 32 | + * |
| 33 | + * A GGMA context represents the environment for inference. |
| 34 | + * It includes model, computation graph, KV caches, and other resources for token generation. |
| 35 | + */ |
| 36 | +typedef struct ggma_context ggma_context; |
| 37 | + |
| 38 | +/** |
| 39 | + * @brief Creates a context from a package path. |
| 40 | + * |
| 41 | + * This function initializes a context for inference from the specified package path. |
| 42 | + * Once the context is no longer needed, it must be destroyed by calling |
| 43 | + * {@link ggma_free_context}. |
| 44 | + * |
| 45 | + * @param[out] context A pointer to the variable that will receive the new context handle. |
| 46 | + * @param[in] package_path The path to the GGMA package directory. |
| 47 | + * @return @c GGMA_STATUS_NO_ERROR on success, or an appropriate error code on failure. |
| 48 | + */ |
| 49 | +GGMA_STATUS ggma_create_context(ggma_context **context, const char *package_path); |
| 50 | + |
| 51 | +/** |
| 52 | + * @brief Closes a GGMA context and releases its resources. |
| 53 | + * |
| 54 | + * This function deallocates all resources associated with the context, including |
| 55 | + * the GGMA package it was created with. After this function returns, the context |
| 56 | + * handle is invalid and must not be used. |
| 57 | + * |
| 58 | + * @param[in] context The context to close. |
| 59 | + * @return @c GGMA_STATUS_NO_ERROR on success, or an appropriate error code on failure. |
| 60 | + */ |
| 61 | +GGMA_STATUS ggma_free_context(ggma_context *context); |
| 62 | + |
| 63 | +#ifdef __cplusplus |
| 64 | +} |
| 65 | +#endif |
| 66 | + |
| 67 | +#endif // __GGMA_GGMA_CONTEXT_H__ |
0 commit comments