ttnn.repeat

ttnn.repeat(input_tensor: ttnn.Tensor, repetition_vector: SmallVector, *, memory_config: ttnn.MemoryConfig = None, optional_output_tensor: ttnn.Tensor = None) ttnn.Tensor

Returns a new tensor filled with repetition of input input_tensor according to number of times specified in shape.

Parameters:
  • input_tensor (ttnn.Tensor)the input tensor.

  • repetition_vector (SmallVector)The number of repetitions for each dimension.

Keyword Arguments:
  • memory_config (ttnn.MemoryConfig, optional)Memory configuration for the operation. Defaults to None.

  • optional_output_tensor (ttnn.Tensor, optional)Preallocated output tensor. Defaults to None.

Returns:

ttnn.Tensorthe output tensor.

Example

# Create a tensor to repeat
input_tensor = torch.tensor([[1, 2], [3, 4]])
input_tensor_tt = ttnn.from_torch(input_tensor, device=device)

# Repeat the tensor along specified dimensions
repeated_tensor = ttnn.repeat(input_tensor_tt, (1, 2))
logger.info("Repeated Tensor Shape:", repeated_tensor.shape)  # Repeated Tensor Shape: Shape([2, 4])