r"""Computes dot-product of two vectors ``inp1`` and ``inp2``. inputs must be 1-dimensional or scalar. A scalar input is automatically broadcasted. Refer to :func:`~.matmul` for more general usage. Args: inp1: first vector. inp2: second vector. Returns: outp
(inp1: Tensor, inp2: Tensor)
| 827 | |
| 828 | |
| 829 | def dot(inp1: Tensor, inp2: Tensor) -> Tensor: |
| 830 | r"""Computes dot-product of two vectors ``inp1`` and ``inp2``. |
| 831 | inputs must be 1-dimensional or scalar. A scalar input is automatically broadcasted. |
| 832 | Refer to :func:`~.matmul` for more general usage. |
| 833 | |
| 834 | Args: |
| 835 | inp1: first vector. |
| 836 | inp2: second vector. |
| 837 | |
| 838 | Returns: |
| 839 | output value. |
| 840 | |
| 841 | Examples: |
| 842 | >>> import numpy as np |
| 843 | >>> data1 = Tensor(np.arange(0, 6, dtype=np.float32)) |
| 844 | >>> data2 = Tensor(np.arange(0, 6, dtype=np.float32)) |
| 845 | >>> out = F.dot(data1, data2) |
| 846 | >>> out.numpy() |
| 847 | array(55., dtype=float32) |
| 848 | """ |
| 849 | op = builtin.Dot() |
| 850 | assert ( |
| 851 | inp1.ndim <= 1 and inp2.ndim <= 1 |
| 852 | ), "Input tensors for dot must be 1-dimensional or scalar" |
| 853 | (result,) = apply(op, inp1, inp2) |
| 854 | return result |
| 855 | |
| 856 | |
| 857 | def svd(inp: Tensor, full_matrices=False, compute_uv=True) -> Tensor: |