outer

tripy.outer(vec1: Tensor, vec2: Tensor) Tensor[source]

Computes the outer product of 1-d vectors vec1 and vec2, such that the output shape is \((m, n)\) if the inputs are of size \((m,)\) and \((n,)\) respectively.

Parameters:
  • vec1 (Tensor) – [dtype=T1] The first 1d input vector.

  • vec2 (Tensor) – [dtype=T1] The second 1d input vector.

Returns:

[dtype=T1] The outer product of the input vectors.

Return type:

Tensor

TYPE CONSTRAINTS:
Example
Example
1v1 = tp.arange(5, dtype=tp.float32)
2v2 = tp.arange(4, dtype=tp.float32)
3output = tp.outer(v1, v2)
>>> v1
tensor([0.0000, 1.0000, 2.0000, 3.0000, 4.0000], dtype=float32, loc=gpu:0, shape=(5,))
>>> v2
tensor([0.0000, 1.0000, 2.0000, 3.0000], dtype=float32, loc=gpu:0, shape=(4,))
>>> output
tensor(
    [[0.0000, 0.0000, 0.0000, 0.0000],
     [0.0000, 1.0000, 2.0000, 3.0000],
     [0.0000, 2.0000, 4.0000, 6.0000],
     [0.0000, 3.0000, 6.0000, 9.0000],
     [0.0000, 4.0000, 8.0000, 12.0000]], 
    dtype=float32, loc=gpu:0, shape=(5, 4))