# Dot¶

Dot  //  Generalized dot product operation


## Description¶

Generalized dot product operation, including scalar-tensor product, matrix-vector product, and matrix multiplication.

A few common cases are as follows:

• If $$m = 0$$ and $$n = 1$$ or $$p = 1$$, the operation is a scalar-tensor product.
• If $$m = 1$$, $$n = 2$$, and $$p = 1$$, the operation is a matrix-vector product.
• If $$m = 1$$ and $$n = p = 2$$, the operation is a matrix multiplication.

### Inputs¶

Name Element Type Shape
arg0 any $$(i_1,\dots,i_n,j_1,\dots,j_m)$$
arg1 same as arg0 $$(j_1,\ldots,j_m,k_1,\dots,k_p)$$

### Attributes¶

Name
reduction_axes_count size_t The number of axes to reduce through dot-product (corresponds to $$m$$ in the formulas above)

### Outputs¶

Name Element Type Shape
output same as arg0 $$(i_1,\ldots,i_n,k_1,\dots,k_p)$$

## Mathematical Definition¶

$\begin{split}\mathtt{output}_{i_1,\dots,i_n,k_1,\ldots,k_p} = \begin{cases} \mathtt{arg0}_{i_1,\dots,i_n} \cdot \mathtt{arg1}_{k_1,\dots,k_p}&\text{if }m=0,\\ \sum_{j_1, \ldots, j_m} \mathtt{arg0}_{i_1,\dots,i_n,j_1,\dots,j_m} \cdot \mathtt{arg1}_{j_1,\ldots,j_m,k_1,\ldots,k_p} &\text{otherwise}. \end{cases}\end{split}$

## Backprop¶

To be documented.

## C++ Interface¶

class Dot : public ngraph::op::Op

Generalized dot product operation, including scalar-tensor product, matrix-vector product, and matrix multiplication.

Public Functions

Dot(const std::shared_ptr<Node> &arg0, const std::shared_ptr<Node> &arg1, size_t reduction_axes_count, bool has_reduction_axes_count = true)

Constructs a dot product operation.

Parameters
• arg0: The node producing the first argument.
• arg1: The node producing the second argument.
• reduction_axes_count: The number of axes to dot.

Dot(const std::shared_ptr<Node> &arg0, const std::shared_ptr<Node> &arg1)

Constructs a dot product operation with default dot-axis selection depending on the inputs.

If arg0 or arg1 is a scalar, there are no dot-axes. Else, there is one dot-axis.

(Note that in particular, this results in scalar-tensor products where one or the other argument is a scalar, a matrix-vector products where arg0 is a matrix and arg1 is a vector, and a matrix multiplication where arg0 and arg1 are both matrices.)

Parameters
• arg0: The node producing the first argument.
• arg1: The node producing the second argument.

void validate_and_infer_types()

Throws if the node is invalid.