concat.rst 2.38 KB
Newer Older
1
.. concat.rst:
2

3 4 5
######
Concat
######
6

7 8 9
.. code-block:: cpp

   Concat  // Concatenation operation 
10 11


12 13
Description
===========
14

L.S. Cook's avatar
L.S. Cook committed
15 16
Produce from ``Nodes`` of ``args`` some outputs with the same attributes

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

Inputs
------

+-----------------+-----------------+------------------------------------------------------+
| Name            | Type            | Notes                                                |
+=================+=================+======================================================+
| ``args``        | ``Nodes``       | All element types the same.                          |
|                 |                 | All shapes the same except on ``concatenation_axis`` |
+-----------------+-----------------+------------------------------------------------------+

Attributes
----------

+-------------------------+----------------------------------+
| Name                    | Notes                            |
+=========================+==================================+
34
| ``concatenation_axis``  | Less than the rank of the shape  |
35 36 37 38 39
+-------------------------+----------------------------------+

Outputs
-------

40 41 42 43 44 45
+-----------------+-------------------------+----------------------------------------------------+
| Name            | Element Type            | Shape                                              |
+=================+=========================+====================================================+
| ``output``      | Same as ``args``         | Same as ``arg`` on non-``concatenation_axis``     |
|                 |                          | Sum of ``concatenation_axis`` lengths of ``args`` |
+-----------------+-------------------------+----------------------------------------------------+
46 47 48 49 50 51 52 53 54 55 56 57


Mathematical Definition
=======================

We map each tensor in ``args`` to a segment of ``output`` based on the
coordinate at ``coordinate_axis``.

Let

.. math::

58
   s(i) &= \sum_{j<i} \mathtt{args}[i].\mathtt{shape}\left[\mathtt{concatenation_axis}\right]\\
59 60
   t(i) &= \text{The greatest }j\text{ such that }i \ge s(j)\\
   p(C)_i &= \begin{cases}
61
   C_i-s(t(i))&\text{if }i==\mathtt{concatenation_axis}\\
62 63
   C_i&\text{otherwise}
   \end{cases}\\
64
   \mathtt{output}_C&=\mathtt{args}[t(C_i)]_{p(C)}
65 66 67 68 69 70 71 72 73 74 75 76



Backprop
========

We slice the backprop value into the backprops associated with the inputs.


C++ Interface
=============

77 78
.. doxygenclass:: ngraph::op::Concat
   :project: ngraph
79
   :members: