full_like

tripy.full_like(input: Tensor, value: Tensor | Number, dtype: dtype | None = None) Tensor[source]

Returns a tensor of the same shape and data type as the input tensor, with all values set to the specified value.

Parameters:
  • input (Tensor) – [dtype=T1] Input tensor.

  • value (Tensor | Number) – A scalar value to fill the resulting tensor.

  • dtype (dtype | None) – [dtype=T2] The desired data type. This will override the data type inferred from the input tensor.

Returns:

[dtype=T2] A tensor of the same shape and data type (unless dtype is provided) as the input.

Return type:

Tensor

TYPE CONSTRAINTS:
Example
Example
1input = tp.Tensor([[1, 2], [3, 4]])
2output = tp.full_like(input, value=2)
>>> input
tensor(
    [[1, 2],
     [3, 4]], 
    dtype=int32, loc=gpu:0, shape=(2, 2))
>>> output
tensor(
    [[2, 2],
     [2, 2]], 
    dtype=int32, loc=gpu:0, shape=(2, 2))