|
3 | 3 | Convert Tensor |
4 | 4 | ~~~~~~~~~~~~~~ |
5 | 5 |
|
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. |
8 | 8 |
|
9 | | - For example, the function can: |
| 9 | +For example, the function can: |
10 | 10 |
|
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 |
12 | 12 |
|
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 |
16 | 16 |
|
17 | | -.. |
| 17 | +Conversion is performed using: |
18 | 18 |
|
19 | | - Conversion is performed using |
| 19 | +- rounding when the number of significant bits increases |
20 | 20 |
|
21 | | - - rounding when the number of significant bits increases. |
| 21 | +- saturation when the number of significant bits decreases |
22 | 22 |
|
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. |
24 | 25 |
|
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. |
26 | 31 |
|
27 | | - This operation does not change tensor shape. It copies it from input |
28 | | - to output. |
| 32 | +.. _api-18: |
29 | 33 |
|
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 | +^^^^^^^^^^^^^^^^ |
35 | 36 |
|
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 |
37 | 52 |
|
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 | + +-----------------------+-----------------------+ |
55 | 62 |
|
| 63 | +**Returns** - ``status code`` |
| 64 | + |
56 | 65 | .. _conditions-for-applying-the-function-7: |
57 | 66 |
|
58 | 67 | Conditions for Applying the Function |
59 | 68 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
60 | 69 |
|
61 | | - - Input must be a valid tensor (see :ref:`mli_tns_struct`). |
| 70 | +- Input must be a valid tensor (see :ref:`mli_tns_struct`). |
62 | 71 |
|
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). |
66 | 75 |
|
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``). |
69 | 78 |
|
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. |
72 | 81 |
|
0 commit comments