[doc] Add doxygen tags
authorYongjoo Ahn <yongjoo1.ahn@samsung.com>
Fri, 17 Jan 2025 06:46:04 +0000 (15:46 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 17 Jan 2025 10:08:09 +0000 (19:08 +0900)
- Add doxygen tags to all source codes.

Signed-off-by: Yongjoo Ahn <yongjoo1.ahn@samsung.com>
doc/hal_ml_doc.h [new file with mode: 0644]
include/hal-ml-interface-1.h
include/hal-ml-interface.h
include/hal-ml-types.h
include/hal-ml.h
src/hal-api-ml.c

diff --git a/doc/hal_ml_doc.h b/doc/hal_ml_doc.h
new file mode 100644 (file)
index 0000000..3f03f3c
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * High level documentation of the HAL ML
+ * Copyright (C) 2025 Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file    hal_ml_doc.h
+ * @date    15 Jan 2025
+ * @brief   High level documentation of the HAL ML
+ * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ * @see     https://github.com/nnstreamer/nnstremaer
+ * @bug     No known bugs except for NYI items
+ *
+ * @details
+ *    This file contains high level documentation of the HAL ML.
+ */
+
+#ifndef __TIZEN_HAL_ML_DOC_H__
+#define __TIZEN_HAL_ML_DOC_H__
+
+
+/**
+ * @defgroup HALAPI_HAL_ML_MODULE ML
+ * @brief The @ref HALAPI_HAL_ML_MODULE provides functions for ml.
+ *
+ * @section HALAPI_HAL_ML_MODULE_HEADER Required Header
+ *   \#include <hal-ml.h>
+ *
+ * @section HALAPI_HAL_ML_MODULE_OVERVIEW Overview
+ * Tizen ML API may require a hardware device to accelerate its job.
+ * This HAL ML provides an interface for Tizen ML API (NNStreamer's tensor_filter subplugin) to use such hardware acceleration devices (NPU, ...) if available.
+ */
+
+#endif /* __TIZEN_HAL_ML_DOC_H__ */
index 38b75a6aa79b9a80e0211f9400758533607b6532..80b00fed27aa1b5fc33c2c61c3ebf557ec99458d 100644 (file)
@@ -1,3 +1,24 @@
+/**
+ * HAL (Hardware Abstract Layer) interface API for ML
+ *
+ * Copyright (C) 2025 Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file    hal-ml-interface-1.h
+ * @date    15 Jan 2025
+ * @brief   HAL (Hardware Abstract Layer) interface API for ML
+ * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ * @see     https://github.com/nnstreamer/nnstremaer
+ * @bug     No known bugs except for NYI items
+ *
+ * @details
+ *    This is the header file for the HAL ML interface version 1.
+ */
+
+#ifndef __HAL_ML_INTERFACE_1__
+#define __HAL_ML_INTERFACE_1__
+
 #include "tensor_typedef.h"
 #include "nnstreamer_plugin_api_filter.h"
 
 
 #ifdef __cplusplus
 extern "C" {
-#endif
+#endif /* __cplusplus */
 
+/**
+ * @addtogroup HALAPI_HAL_ML_MODULE
+ * @{
+ */
+
+/**
+ * @brief The HAL backend structure for ML. This should be implemented by each HAL backend.
+ * @since HAL_MODULE_ML 1.0
+ */
 typedef struct _hal_backend_ml_funcs {
+  /**< Initialize HL backend handle */
   int (*init)(void **backend_private);
+  /**< Deinitialize HL backend handle */
   int (*deinit)(void *backend_private);
 
+  /**< Configure ml framework */
   int (*configure_instance)(void *backend_private, const GstTensorFilterProperties *prop);
+  /**< Invoke */
   int (*invoke)(void *backend_private, const GstTensorMemory *input, GstTensorMemory *output);
+  /**< Invoke dynamic */
   int (*invoke_dynamic)(void *backend_private, GstTensorFilterProperties *prop, const GstTensorMemory *input, GstTensorMemory *output);
+  /**< Get framework info */
   int (*get_framework_info)(void *backend_private, GstTensorFilterFrameworkInfo *framework_info);
+  /**< Get model info */
   int (*get_model_info)(void *backend_private, model_info_ops ops, GstTensorsInfo *in_info, GstTensorsInfo *out_info);
+  /**< Handle event */
   int (*event_handler)(void *backend_private, event_ops ops, GstTensorFilterFrameworkEventData *data);
 } hal_backend_ml_funcs;
 
+/**
+ * @}
+ */
+
 #ifdef __cplusplus
 }
-#endif
+#endif /* __cplusplus */
+#endif /* __HAL_ML_INTERFACE_1__ */
index 7ab165eadc1555f763a5091ecf9208146ad90f7d..054ca4fc20567d60484080f6fb17c8f4f84355f4 100644 (file)
@@ -1 +1,21 @@
+/**
+ * HAL (Hardware Abstract Layer) interface API for ML
+ *
+ * Copyright (C) 2025 Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file    hal-ml-interface.h
+ * @date    15 Jan 2025
+ * @brief   HAL (Hardware Abstract Layer) interface API for ML
+ * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ * @see     https://github.com/nnstreamer/nnstremaer
+ * @bug     No known bugs except for NYI items
+ */
+
+#ifndef __HAL_ML_INTERFACE__
+#define __HAL_ML_INTERFACE__
+
 #include "hal-ml-interface-1.h"
+
+#endif /* __HAL_ML_INTERFACE__ */
index 737319be07a22dcfc1e7cb47b4360197f08e765f..77f577c62f4b13b0a9f5b6a6d79279a62367c298 100644 (file)
@@ -1,3 +1,18 @@
+/**
+ * Define types for HAL ML
+ *
+ * Copyright (C) 2025 Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file    hal-ml-types.h
+ * @date    15 Jan 2025
+ * @brief   Define types for HAL ML
+ * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ * @see     https://github.com/nnstreamer/nnstremaer
+ * @bug     No known bugs except for NYI items
+ */
+
 #ifndef __HAL_ML_TYPES__
 #define __HAL_ML_TYPES__
 
@@ -8,6 +23,15 @@
 extern "C" {
 #endif /* __cplusplus */
 
+/**
+ * @addtogroup HAL_ML_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the error codes of hal-ml
+ * @since HAL_MODULE_ML 1.0
+ */
 typedef enum hal_ml_error {
   HAL_ML_ERROR_NONE = 0,
   HAL_ML_ERROR_INVALID_PARAMETER = -1,
@@ -19,9 +43,10 @@ typedef enum hal_ml_error {
   HAL_ML_ERROR_RUNTIME_ERROR = -7,
 } hal_ml_error_e;
 
+/**
+ * @}
+ */
 
-typedef void *hal_ml_h;
-typedef void *hal_ml_param_h;
 
 #ifdef __cplusplus
 }
index d1f6098e8073a14c5da375a239c36bfe528b783a..b6e11b44e4f33e8bbf4ecb239c48a4df3bb09981 100644 (file)
-#include "hal-ml-types.h"
+/**
+ * HAL (Hardware Abstract Layer) API for ML
+ *
+ * Copyright (C) 2025 Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file    hal-ml.h
+ * @date    15 Jan 2025
+ * @brief   HAL (Hardware Abstract Layer) API for ML
+ * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ * @see     https://github.com/nnstreamer/nnstremaer
+ * @bug     No known bugs except for NYI items
+ *
+ * @details
+ *  This HAL ML provides an interface for Tizen ML API (NNStreamer's tensor_filter subplugin)
+ *  to use hardware acceleration devices (NPU, ...).
+ */
+
+#ifndef __HAL_ML__
+#define __HAL_ML__
+
+#include <hal-ml-types.h>
 
 #ifdef __cplusplus
 extern "C" {
-#endif
+#endif /* __cplusplus */
+
+/**
+ * @addtogroup HAL_ML_MODULE
+ * @{
+ */
+
+/**
+ * @brief A handle for hal-ml instance
+ * @since HAL_MODULE_ML 1.0
+ */
 typedef void *hal_ml_h;
+
+/**
+ * @brief A handle for hal-ml-param instance
+ * @since HAL_MODULE_ML 1.0
+ */
 typedef void *hal_ml_param_h;
+
+/**
+ * @brief Creates hal-ml-param instance
+ * @since HAL_MODULE_ML 1.0
+ * @remarks The @a param should be released using hal_ml_param_destroy().
+ * @param[out] option Newly created option handle is returned.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ * @retval #HAL_ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
+ */
 int hal_ml_param_create(hal_ml_param_h *param);
+
+/**
+ * @brief Destroys hal-ml-param instance
+ * @since HAL_MODULE_ML 1.0
+ * @param[in] param The handle of the param instance to be destroyed.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ */
 int hal_ml_param_destroy(hal_ml_param_h param);
+
+/**
+ * @brief Sets a parameter for hal-ml-param instance
+ * @since HAL_MODULE_ML 1.0
+ * @param[in] param The handle of the param instance.
+ * @param[in] key The key of the parameter to set.
+ * @param[in] value The value of the parameter to set.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ */
 int hal_ml_param_set(hal_ml_param_h param, const char *key, void *value);
-// int hal_ml_param_get(hal_ml_param_h param, const char *key, void **value);
 
+/**
+ * @brief Creates hal-ml instance
+ * @since HAL_MODULE_ML 1.0
+ * @remarks The @a handle should be released using hal_ml_destroy().
+ * @param[in] backend_name The name of the backend to use.
+ * @param[out] handle Newly created handle is returned.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ * @retval #HAL_ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
+ */
 int hal_ml_create(const char *backend_name, hal_ml_h *handle);
+
+/**
+ * @brief Destroys hal-ml instance
+ * @since HAL_MODULE_ML 1.0
+ * @param[in] handle The handle of the instance to be destroyed.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ */
 int hal_ml_destroy(hal_ml_h handle);
+
+/**
+ * @brief Sends a request to hal-ml instance
+ * @since HAL_MODULE_ML 1.0
+ * @param[in] handle The handle of the instance.
+ * @param[in] request_name The name of the request.
+ * @param[in] param The parameters for the request.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ */
 int hal_ml_request(hal_ml_h handle, const char *request_name, hal_ml_param_h param);
 
+/**
+ * @brief Invokes the hal-ml instance with the given data.
+ * @since HAL_MODULE_ML 1.0
+ * @param[in] handle The handle of the instance.
+ * @param[in] input The input data for the invoke.
+ * @param[in, out] output The output data for the invoke.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ */
 int hal_ml_request_invoke(hal_ml_h handle, const void *input, void *output);
+
+/**
+ * @brief Invoke dynamic the hal-ml instance with the given data.
+ * @since HAL_MODULE_ML 1.0
+ * @param[in] handle The handle of the instance.
+ * @param[in, out] prop The properties for the invoke dynamic.
+ * @param[in] input The input data for the invoke.
+ * @param[in, out] output The output data for the invoke.
+ * @return @c 0 on success. Otherwise a negative error value.
+ * @retval #HAL_ML_ERROR_NONE Successful.
+ * @retval #HAL_ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
+ */
 int hal_ml_request_invoke_dynamic(hal_ml_h handle, void *prop, const void *input, void *output);
 
+/**
+ * @}
+ */
+
 #ifdef __cplusplus
 }
-#endif
\ No newline at end of file
+#endif /* __cplusplus */
+#endif /* __HAL_ML__ */
index f20b9db66003495fabbb96a2633e96f17d6c1acf..c3d18db6044bf920374e339f1d2d9443f9e6b101 100644 (file)
@@ -1,4 +1,21 @@
-/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * HAL (Hardware Abstract Layer) API for ML
+ *
+ * Copyright (C) 2025 Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file    hal-api-ml.c
+ * @date    15 Jan 2025
+ * @brief   HAL (Hardware Abstract Layer) API for ML
+ * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
+ * @see     https://github.com/nnstreamer/nnstremaer
+ * @bug     No known bugs except for NYI items
+ *
+ * @details
+ *  This HAL ML provides an interface for Tizen ML API (NNStreamer's tensor_filter subplugin)
+ *  to use hardware acceleration devices (NPU, ...).
+ */
 
 #include <glib.h>
 
 #include "hal-ml-interface.h"
 #include "hal-ml.h"
 
-#if defined(__TIZEN__)
 #include <dlog.h>
 #define LOG_TAG "HAL_ML"
 #define _D(fmt, args...)  SLOGD(fmt, ##args)
 #define _I(fmt, args...)  SLOGI(fmt, ##args)
 #define _W(fmt, args...)  SLOGW(fmt, ##args)
 #define _E(fmt, args...)  SLOGE(fmt, ##args)
-#else
-#include <glib.h>
-
-#define _D g_debug
-#define _I g_info
-#define _W g_warning
-#define _E g_critical
-#endif
 
 
 typedef struct _hal_ml_s {