DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anup Prabhu <aprabhu@marvell.com>
To: Srikanth Yalavarthi <syalavarthi@marvell.com>,
	Srikanth Yalavarthi <syalavarthi@marvell.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Shivah Shankar Shankar Narayan Rao <sshankarnara@marvell.com>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	Prince Takkar <ptakkar@marvell.com>,
	Parijat Shukla <pshukla@marvell.com>
Subject: RE: [PATCH v4 1/4] mldev: add headers for internal ML functions
Date: Wed, 1 Feb 2023 13:54:52 +0000	[thread overview]
Message-ID: <BL0PR18MB37481BDC8D5E1BD36BC455B5A5D19@BL0PR18MB3748.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20230201090454.14649-2-syalavarthi@marvell.com>

[-- Attachment #1: Type: text/plain, Size: 11912 bytes --]



-----Original Message-----
From: Srikanth Yalavarthi <syalavarthi@marvell.com> 
Sent: Wednesday, February 1, 2023 2:35 PM
To: Srikanth Yalavarthi <syalavarthi@marvell.com>
Cc: dev@dpdk.org; Shivah Shankar Shankar Narayan Rao <sshankarnara@marvell.com>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Anup Prabhu <aprabhu@marvell.com>
Subject: [PATCH v4 1/4] mldev: add headers for internal ML functions

Added header files for internal ML utility routines to convert IO type and format to string, IO type to size and routines to convert data types.

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 lib/mldev/meson.build   |   2 +
 lib/mldev/mldev_utils.c |   5 +
 lib/mldev/mldev_utils.h | 345 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 352 insertions(+)
 create mode 100644 lib/mldev/mldev_utils.c  create mode 100644 lib/mldev/mldev_utils.h

Acked-by: Anup Prabhu <aprabhu@marvell.com>

diff --git a/lib/mldev/meson.build b/lib/mldev/meson.build index 5c99532c1a..452b83a480 100644
--- a/lib/mldev/meson.build
+++ b/lib/mldev/meson.build
@@ -4,6 +4,7 @@
 sources = files(
         'rte_mldev_pmd.c',
         'rte_mldev.c',
+        'mldev_utils.c',
 )
 
 headers = files(
@@ -16,6 +17,7 @@ indirect_headers += files(
 
 driver_sdk_headers += files(
         'rte_mldev_pmd.h',
+        'mldev_utils.h',
 )
 
 deps += ['mempool']
diff --git a/lib/mldev/mldev_utils.c b/lib/mldev/mldev_utils.c new file mode 100644 index 0000000000..9dbbf013a0
--- /dev/null
+++ b/lib/mldev/mldev_utils.c
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Marvell.
+ */
+
+#include "mldev_utils.h"
diff --git a/lib/mldev/mldev_utils.h b/lib/mldev/mldev_utils.h new file mode 100644 index 0000000000..04cdaab567
--- /dev/null
+++ b/lib/mldev/mldev_utils.h
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Marvell.
+ */
+
+#ifndef _RTE_MLDEV_UTILS_H_
+#define _RTE_MLDEV_UTILS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ *
+ * RTE ML Device PMD utility API
+ *
+ * These APIs for the use from ML drivers, user applications shouldn't use them.
+ *
+ */
+
+#include <rte_compat.h>
+#include <rte_mldev.h>
+
+/**
+ * @internal
+ *
+ * Get the size an ML IO type in bytes.
+ *
+ * @param[in] type
+ *	Enumeration of ML IO data type.
+ *
+ * @return
+ *	- > 0, Size of the data type in bytes.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_type_size_get(enum rte_ml_io_type type);
+
+/**
+ * @internal
+ *
+ * Get the name of an ML IO type.
+ *
+ * @param[in] type
+ *	Enumeration of ML IO data type.
+ * @param[in] str
+ *	Address of character array.
+ * @param[in] len
+ *	Length of character array.
+ */
+__rte_internal
+void
+rte_ml_io_type_to_str(enum rte_ml_io_type type, char *str, int len);
+
+/**
+ * @internal
+ *
+ * Get the name of an ML IO format.
+ *
+ * @param[in] type
+ *	Enumeration of ML IO format.
+ * @param[in] str
+ *	Address of character array.
+ * @param[in] len
+ *	Length of character array.
+ */
+__rte_internal
+void
+rte_ml_io_format_to_str(enum rte_ml_io_format format, char *str, int 
+len);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in single precision floating 
+format (float32) to signed 8-bit
+ * integer format (INT8).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ * @param[out] output
+ *	Output buffer to store INT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float32_to_int8(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in signed 8-bit integer format 
+(INT8) to single precision
+ * floating format (float32).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing INT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
+ * @param[out] output
+ *	Output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_int8_to_float32(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in single precision floating 
+format (float32) to unsigned
+ * 8-bit integer format (UINT8).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ * @param[out] output
+ *	Output buffer to store UINT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float32_to_uint8(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in unsigned 8-bit integer format 
+(UINT8) to single precision
+ * floating format (float32).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing UINT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
+ * @param[out] output
+ *	Output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_uint8_to_float32(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in single precision floating 
+format (float32) to signed
+ * 16-bit integer format (INT16).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ * @param[out] output
+ *	Output buffer to store INT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float32_to_int16(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in signed 16-bit integer format 
+(INT16) to single precision
+ * floating format (float32).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing INT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ * @param[out] output
+ *	Output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_int16_to_float32(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in single precision floating 
+format (float32) to unsigned
+ * 16-bit integer format (UINT16).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ * @param[out] output
+ *	Output buffer to store UINT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float32_to_uint16(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in unsigned 16-bit integer 
+format (UINT16) to single
+ * precision floating format (float32).
+ *
+ * @param[in] scale
+ *      Scale factor for conversion.
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing UINT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ * @param[out] output
+ *	Output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_uint16_to_float32(float scale, uint64_t nb_elements, void 
+*input, void *output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in single precision floating 
+format (float32) to half
+ * precision floating point format (FP16).
+ *
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float32 numbers. Size of buffer is equal to (nb_elements *4) bytes.
+ * @param[out] output
+ *	Output buffer to store float16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float32_to_float16(uint64_t nb_elements, void *input, void 
+*output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in half precision floating 
+format (FP16) to single precision
+ * floating point format (float32).
+ *
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ * @param[out] output
+ *	Output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float16_to_float32(uint64_t nb_elements, void *input, void 
+*output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in single precision floating 
+format (float32) to brain
+ * floating point format (bfloat16).
+ *
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing float32 numbers. Size of buffer is equal to (nb_elements *4) bytes.
+ * @param[out] output
+ *	Output buffer to store bfloat16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_float32_to_bfloat16(uint64_t nb_elements, void *input, void 
+*output);
+
+/**
+ * @internal
+ *
+ * Convert a buffer containing numbers in brain floating point format 
+(bfloat16) to single precision
+ * floating point format (float32).
+ *
+ * @param[in] nb_elements
+ *	Number of elements in the buffer.
+ * @param[in] input
+ *	Input buffer containing bfloat16 numbers. Size of buffer is equal to (nb_elements * 2)
+ * bytes.
+ * @param[out] output
+ *	Output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
+ *
+ * @return
+ *	- 0, Success.
+ *	- < 0, Error code on failure.
+ */
+__rte_internal
+int
+rte_ml_io_bfloat16_to_float32(uint64_t nb_elements, void *input, void 
+*output);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_MLDEV_UTILS_H_ */
--
2.17.1


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 24980 bytes --]

  reply	other threads:[~2023-02-01 13:55 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 19:35 [PATCH v1 0/4] implementation of ML common code Srikanth Yalavarthi
2022-12-08 19:35 ` [PATCH v1 1/4] common/ml: add initial files for " Srikanth Yalavarthi
2022-12-08 19:35 ` [PATCH v1 2/4] common/ml: add data type conversion routines Srikanth Yalavarthi
2022-12-08 19:35 ` [PATCH v1 3/4] common/ml: add generic type conversion functions Srikanth Yalavarthi
2022-12-08 19:35 ` [PATCH v1 4/4] common/ml: add Arm NEON type conversion routines Srikanth Yalavarthi
2022-12-12  7:16   ` Ruifeng Wang
2022-12-12 17:25     ` Srikanth Yalavarthi
2022-12-12 17:21 ` [PATCH v1 0/4] implementation of ML common code Srikanth Yalavarthi
2022-12-12 17:21   ` [PATCH v2 1/4] common/ml: add initial files for " Srikanth Yalavarthi
2022-12-12 17:21   ` [PATCH v2 2/4] common/ml: add common utility functions Srikanth Yalavarthi
2022-12-12 17:21   ` [PATCH v2 3/4] common/ml: add scalar type conversion functions Srikanth Yalavarthi
2022-12-12 17:21   ` [PATCH v2 4/4] common/ml: add Arm NEON type conversion routines Srikanth Yalavarthi
2022-12-13  9:04     ` Ruifeng Wang
2022-12-20 17:52   ` [PATCH v3 0/4] implementation of ML common code Srikanth Yalavarthi
2022-12-20 17:52     ` [PATCH v3 1/4] common/ml: add initial files for " Srikanth Yalavarthi
2022-12-20 19:04       ` Stephen Hemminger
2022-12-20 19:19         ` [EXT] " Srikanth Yalavarthi
2022-12-20 17:52     ` [PATCH v3 2/4] common/ml: add common utility functions Srikanth Yalavarthi
2022-12-20 17:52     ` [PATCH v3 3/4] common/ml: add scalar type conversion functions Srikanth Yalavarthi
2022-12-20 17:52     ` [PATCH v3 4/4] common/ml: add Arm NEON type conversion routines Srikanth Yalavarthi
2022-12-21  3:08       ` Ruifeng Wang
2022-12-20 19:06     ` [PATCH v3 0/4] implementation of ML common code Stephen Hemminger
2022-12-20 19:17       ` [EXT] " Srikanth Yalavarthi
2023-01-25 13:18     ` Thomas Monjalon
2023-01-25 13:25       ` [EXT] " Srikanth Yalavarthi
2023-01-25 13:55         ` Thomas Monjalon
2023-01-25 14:59           ` Srikanth Yalavarthi
2023-01-26 10:57             ` Thomas Monjalon
2023-01-27  6:40               ` Jerin Jacob
2023-01-27  8:50                 ` Thomas Monjalon
2023-01-27  9:02                   ` Jerin Jacob
2023-01-27  9:26                     ` Thomas Monjalon
2023-01-27 10:28                       ` Jerin Jacob
2023-01-31 13:44                         ` Srikanth Yalavarthi
2023-02-01  9:15                           ` Srikanth Yalavarthi
2023-02-01  9:04 ` [PATCH v4 0/4] Implementation " Srikanth Yalavarthi
2023-02-01  9:04   ` [PATCH v4 1/4] mldev: add headers for internal ML functions Srikanth Yalavarthi
2023-02-01 13:54     ` Anup Prabhu [this message]
2023-02-01 15:28       ` Thomas Monjalon
2023-02-01  9:04   ` [PATCH v4 2/4] mldev: implement ML IO type handling functions Srikanth Yalavarthi
2023-02-01 13:53     ` Anup Prabhu
2023-02-01 14:01     ` Anup Prabhu
2023-02-01 14:15     ` Anup Prabhu
2023-02-01 14:26     ` Anup Prabhu
2023-02-01  9:04   ` [PATCH v4 3/4] mldev: add scalar type conversion functions Srikanth Yalavarthi
2023-02-01  9:04   ` [PATCH v4 4/4] mldev: add Arm NEON type conversion routines Srikanth Yalavarthi
2023-02-01  9:12 ` [PATCH v5 0/4] Implementation of ML common code Srikanth Yalavarthi
2023-02-01  9:12   ` [PATCH v5 1/4] mldev: add headers for internal ML functions Srikanth Yalavarthi
2023-02-01  9:12   ` [PATCH v5 2/4] mldev: implement ML IO type handling functions Srikanth Yalavarthi
2023-02-02  4:20     ` Anup Prabhu
2023-02-01  9:12   ` [PATCH v5 3/4] mldev: add scalar type conversion functions Srikanth Yalavarthi
2023-02-01  9:12   ` [PATCH v5 4/4] mldev: add Arm NEON type conversion routines Srikanth Yalavarthi
2023-02-07 16:00 ` [PATCH v6 0/4] Implementation of ML common code Srikanth Yalavarthi
2023-02-07 16:00   ` [PATCH v6 1/4] mldev: add headers for internal ML functions Srikanth Yalavarthi
2023-03-09 20:44     ` Thomas Monjalon
2023-02-07 16:00   ` [PATCH v6 2/4] mldev: implement ML IO type handling functions Srikanth Yalavarthi
2023-02-07 16:00   ` [PATCH v6 3/4] mldev: add scalar type conversion functions Srikanth Yalavarthi
2023-02-07 16:00   ` [PATCH v6 4/4] mldev: add Arm NEON type conversion routines Srikanth Yalavarthi
2023-03-09 21:37   ` [PATCH v6 0/4] Implementation of ML common code Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BL0PR18MB37481BDC8D5E1BD36BC455B5A5D19@BL0PR18MB3748.namprd18.prod.outlook.com \
    --to=aprabhu@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=pshukla@marvell.com \
    --cc=ptakkar@marvell.com \
    --cc=sshankarnara@marvell.com \
    --cc=syalavarthi@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).