Skip to content

Commit 181835e

Browse files
committed
incorporating review comments
1 parent 60e9e29 commit 181835e

39 files changed

+2909
-2572
lines changed

doc/documents/MLI_FP_data_format/MLI_FP_data_format.rst

Lines changed: 220 additions & 220 deletions
Large diffs are not rendered by default.

doc/documents/MLI_helpers/MLI_helpers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
MLI helpers
44
===========
55

6-
This is a set of utility functions for getting information from data
7-
structures and performing various operations on it.
6+
The MLI helpers are a set of utility functions for getting information from data
7+
structures and performing various operations on it.
88

99
.. toctree::
1010
:maxdepth: 2

doc/documents/MLI_helpers/convert_tensor.rst

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,79 @@
33
Convert Tensor
44
~~~~~~~~~~~~~~
55

6-
This function copies elements from input tensor to output with data
7-
conversion according to the output tensor type parameters.
6+
This function copies elements from the input tensor to the output with data
7+
conversion according to the output tensor type parameters.
88

9-
For example, the function can:
9+
For example, the function can:
1010

11-
- convert data according to new element type: ``fx16`` to ``fx8`` and backward
11+
- convert data according to new element type: ``fx16`` to ``fx8`` and backward
1212

13-
- change data according to new data parameter: increase/decrease the
14-
number of fractional bits while keeping the same element type for
15-
FX data
13+
- change data according to new data parameter: increase/decrease the
14+
number of fractional bits while keeping the same element type for
15+
FX data
1616

17-
..
17+
Conversion is performed using:
1818

19-
Conversion is performed using
19+
- rounding when the number of significant bits increases
2020

21-
- rounding when the number of significant bits increases.
21+
- saturation when the number of significant bits decreases
2222

23-
- saturation when the number of significant bits decreases.
23+
This operation does not change tensor shape. It copies it from input
24+
to output.
2425

25-
..
26+
This kernel performs in-place computation, but only for conversions
27+
without increasing data size, so that that it does not lead to
28+
undefined behavior. Therefore, output and input might point to exactly the
29+
same memory (but without shift) except during ``fx8`` to ``fx16`` conversion.
30+
In-place computation might affect performance for some platforms.
2631

27-
This operation does not change tensor shape. It copies it from input
28-
to output.
32+
.. _api-18:
2933

30-
Kernel can perform in-place computation, but only for conversions
31-
without increasing data size, so that that it does not lead to
32-
undefined behavior. Therefore, output and input might point to exactly the
33-
same memory (but without shift) except ``fx8`` to ``fx16`` conversion.
34-
In-place computation might affect performance for some platforms.
34+
Kernel Interface
35+
^^^^^^^^^^^^^^^^
3536

36-
.. _api-18:
37+
Prototype
38+
'''''''''
39+
40+
.. code:: c
41+
42+
mli_status mli_hlp_convert_tensor(
43+
mli_tensor *in,
44+
mli_tensor *out
45+
);
46+
..
47+
48+
Parameters
49+
''''''''''
50+
51+
.. table:: Kernel Interface Parameters
3752

38-
API
39-
^^^
40-
41-
+-----------------------+-----------------------+----------------------------------------------+
42-
| **Prototype** |.. code:: c |
43-
| | |
44-
| | mli_status mli_hlp_convert_tensor(mli_tensor *in, mli_tensor *out); |
45-
| | |
46-
+-----------------------+-----------------------+----------------------------------------------+
47-
| **Parameters** | ``in`` | [IN] Pointer to input |
48-
| | | tensor |
49-
+-----------------------+-----------------------+----------------------------------------------+
50-
| | ``start_dim`` | [OUT] Pointer to |
51-
| | | output tensor |
52-
+-----------------------+-----------------------+----------------------------------------------+
53-
| **Returns** | ``status code`` | |
54-
+-----------------------+-----------------------+----------------------------------------------+
53+
+-----------------------+-----------------------+
54+
| **Parameters** | **Description** |
55+
+=======================+=======================+
56+
| ``in`` | [IN] Pointer to input |
57+
| | tensor |
58+
+-----------------------+-----------------------+
59+
| ``start_dim`` | [OUT] Pointer to |
60+
| | output tensor |
61+
+-----------------------+-----------------------+
5562

63+
**Returns** - ``status code``
64+
5665
.. _conditions-for-applying-the-function-7:
5766

5867
Conditions for Applying the Function
5968
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6069

61-
- Input must be a valid tensor (see :ref:`mli_tns_struct`).
70+
- Input must be a valid tensor (see :ref:`mli_tns_struct`).
6271

63-
- Before processing the output tensor must contain a valid pointer to a
64-
buffer with sufficient capacity enough for storing the result
65-
(that is, the total amount of elements in input tensor).
72+
- Before processing, the output tensor must contain a valid pointer to a
73+
buffer with sufficient capacity for storing the result
74+
(that is, the total amount of elements in input tensor).
6675

67-
- The output tensor also must contain valid element type and its
68-
parameter (``el_params.fx.frac_bits``)
76+
- The output tensor also must contain valid element type and its
77+
parameter (``el_params.fx.frac_bits``).
6978

70-
- Before processing, the output tensor does not have to contain valid
71-
shape and rank - they are copied from input tensor.
79+
- Before processing, the output tensor does not have to contain valid
80+
shape and rank - they are copied from input tensor.
7281

doc/documents/MLI_helpers/count_no_elements.rst

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,63 @@
33
Count Number of Elements
44
~~~~~~~~~~~~~~~~~~~~~~~~~
55

6-
Function counts the number of elements in a tensor starting from the
7-
provided dimension number (dimension numbering starts from 0):
6+
Function counts the number of elements in a tensor starting from the
7+
provided dimension number (dimension numbering starts from 0):
88

99
.. math:: num\_ of\_ elements = shape\lbrack start\_ dim\rbrack\ *shape\lbrack start\_ dim + 1\rbrack*\ldots*shape\lbrack last\_ dim\rbrack
1010

1111
..
1212
13-
Where:
1413

15-
``num_of_elements`` - Number of accounting elements
14+
Where:
15+
16+
- :math:`num\_ of\_ elements` - number of accounting elements
17+
- :math:`shape` - shape of tensor
18+
- :math:`start\_ dim` – start dimension for counting
19+
- :math:`last\_ dim` - last dimension of tensor (tensor rank-1)
1620

17-
``shape`` - Shape of tensor
21+
This function calculates total number of elements in case
22+
``start_dim = 0``. Function returns 0 if conditions listed
23+
in the following API are violated.
1824

19-
``start_dim`` – Start dimension for counting
25+
.. _api-16:
2026

21-
``last_dim`` - Last dimension of tensor (tensor rank-1)
27+
Kernel Interface
28+
^^^^^^^^^^^^^^^^
2229

23-
Function calculates total number of elements in case
24-
``start_dim = 0``. Function returns 0 if conditions listed
25-
in the following API are violated.
30+
Prototype
31+
'''''''''
2632

27-
.. _api-16:
33+
.. code:: c
34+
35+
uint32_t mli_hlp_count_elem_num(
36+
mli_tensor *in,
37+
uint32_t start_dim
38+
)
39+
..
40+
41+
Parameters
42+
''''''''''
43+
44+
.. table:: Kernel Interface Parameters
2845

29-
API
30-
^^^
31-
32-
+-----------------------+-----------------------+-------------------------------------------------+
33-
| **Prototype** |.. code:: c |
34-
| | |
35-
| | uint32_t mli_hlp_count_elem_num(mli_tensor *in, uint32_t start_dim) |
36-
+-----------------------+-----------------------+-------------------------------------------------+
37-
| **Parameters** | ``in`` | [IN] Pointer to input tensor |
38-
+-----------------------+-----------------------+-------------------------------------------------+
39-
| | ``start_dim`` | [IN] Start dimension for counting |
40-
+-----------------------+-----------------------+-------------------------------------------------+
41-
| **Returns** | ``Number of elements``| |
42-
+-----------------------+-----------------------+-------------------------------------------------+
46+
+-----------------------+-----------------------+
47+
| **Parameters** | **Description** |
48+
+=======================+=======================+
49+
| ``in`` | [IN] Pointer to input |
50+
| | tensor |
51+
+-----------------------+-----------------------+
52+
| ``start_dim`` | [IN] Start dimension |
53+
| | for counting |
54+
+-----------------------+-----------------------+
4355

56+
**Returns** - *num_of_elements*
57+
4458
.. _conditions-for-applying-the-function-5:
4559

4660
Conditions for Applying the Function
4761
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4862

4963
- Input must contain valid rank (less then ``MLI_MAX_RANK``).
5064

51-
- ``start_dim`` must be less than or equal to input rank
65+
- ``start_dim`` must be less than or equal to input rank.

doc/documents/MLI_helpers/get_basic_elem_size.rst

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,41 @@
33
Get Basic Element Size
44
~~~~~~~~~~~~~~~~~~~~~~
55

6-
This function returns size of tensor basic element in bytes. It
7-
returns 0 if conditions listed the following API are violated.
6+
This function returns size of tensor basic element in bytes. It
7+
returns 0 if conditions listed the following API are violated.
88

99
.. _api-15:
1010

11-
API
12-
^^^
13-
14-
+-----------------------+-----------------------+-----------------------+
15-
| |.. code:: c |
16-
| | |
17-
| **Prototype** | uint32_t mli_hlp_count_elem_num |
18-
| | (mli_tensor *in) |
19-
| | |
20-
+-----------------------+-----------------------+-----------------------+
21-
| | | |
22-
| **Parameters** | ``in`` | [IN] Pointer to input |
23-
| | | tensor |
24-
+-----------------------+-----------------------+-----------------------+
25-
| **Returns** | Size of basic element |
26-
| | in bytes |
27-
+-----------------------+-----------------------+-----------------------+
11+
Kernel Interface
12+
^^^^^^^^^^^^^^^^
2813

14+
Prototype
15+
'''''''''
16+
17+
.. code:: c
18+
19+
uint32_t mli_hlp_count_elem_num (mli_tensor *in)
20+
..
21+
22+
Parameters
23+
''''''''''
24+
25+
.. table:: Kernel Interface Parameters
26+
27+
+-----------------------+-----------------------+
28+
| **Parameters** | **Description** |
29+
+=======================+=======================+
30+
| ``in`` | [IN] Pointer to input |
31+
| | tensor |
32+
+-----------------------+-----------------------+
33+
34+
**Returns** - Size of basic element in bytes
35+
2936
.. _conditions-for-applying-the-function-4:
3037

3138
Conditions for Applying the Function
3239
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3340

34-
The function must point to the tensor of supported element type (see
35-
:ref:`mli_elm_enum`).
41+
This function must point to the tensor of supported element type (see
42+
:ref:`mli_elm_enum`).
3643

0 commit comments

Comments
 (0)