function
empty_tensor
empty_tensor[type: DType, rank: Int](shape: StaticIntTuple[rank]) -> Tensor[$0, $1]
Creates an empty Tensor
with the given shape.
For example, here's how to create a new tensor that matches an input shape:
fn gelu[type: DType, rank: Int](x: Tensor[type, rank]) -> Tensor[type, rank]:
var output = empty_tensor[type](x.shape)
# modify the output tensor here...
return output^
Parameters:
- type (
DType
): The tensor data type. - rank (
Int
): The tensor rank.
Args:
- shape (
StaticIntTuple[rank]
): The tensor shape.
Returns:
An empty Tensor
with the specified type and shape.