Skip to main content

function

rand

rand[type: DType](*shape: Int) -> Tensor[$0]

Constructs a new tensor with the specified shape and fills it with random elements.

Parameters:

  • type (DType): The dtype of the tensor.

Args:

  • *shape (Int): The tensor shape.

Returns:

A new tensor of specified shape and filled with random elements.

rand[type: DType](owned shape: TensorShape) -> Tensor[$0]

Constructs a new tensor with the specified shape and fills it with random elements.

Parameters:

  • type (DType): The dtype of the tensor.

Args:

  • shape (TensorShape): The tensor shape.

Returns:

A new tensor of specified shape and filled with random elements.

rand[type: DType](owned spec: TensorSpec) -> Tensor[$0]

Constructs a new tensor with the specified specification and fills it with random elements.

Parameters:

  • type (DType): The dtype of the tensor.

Args:

  • spec (TensorSpec): The tensor specification.

Returns:

A new tensor of specified specification and filled with random elements.