Mojo function
mean
mean(src: Buffer[type, size, address_space]) -> SIMD[$0, 1]
Computes the mean value of the elements in a buffer.
Args:
- src (
Buffer[type, size, address_space]
): The buffer of elements for which the mean is computed.
Returns:
The mean value of the elements in the given buffer.
mean[reduce_axis: Int](src: NDBuffer[type, rank, shape, strides, address_space], dst: NDBuffer[type, rank, shape, create_unknown[::Int](), 0])
Computes the mean across reduce_axis of an NDBuffer.
Parameters:
- reduce_axis (
Int
): The axis to reduce across.
Args:
- src (
NDBuffer[type, rank, shape, strides, address_space]
): The input buffer. - dst (
NDBuffer[type, rank, shape, create_unknown[::Int](), 0]
): The output buffer.
mean[type: DType, input_fn: fn[Int, Int](StaticIntTuple[$1]) capturing -> SIMD[$0, $0], output_fn: fn[Int, Int](StaticIntTuple[$1], SIMD[$0, $0]) capturing -> None, /, single_thread_blocking_override: Bool = 0, target: StringLiteral = "cpu"](input_shape: StaticIntTuple[size], reduce_dim: Int, output_shape: StaticIntTuple[size], context: MojoCallContextPtr = MojoCallContextPtr())
Computes the mean across the input and output shape.
This performs the mean computation on the domain specified by input_shape
,
storing the results using theinput_0_fn
. The results' domain is
output_shape
which are stored using the output_0_fn
.
Parameters:
- type (
DType
): The type of the input and output. - input_fn (
fn[Int, Int](StaticIntTuple[$1]) capturing -> SIMD[$0, $0]
): The function to load the input. - output_fn (
fn[Int, Int](StaticIntTuple[$1], SIMD[$0, $0]) capturing -> None
): The function to store the output. - single_thread_blocking_override (
Bool
): If True, then the operation is run synchronously using a single thread. - target (
StringLiteral
): The target to run on.
Args:
- input_shape (
StaticIntTuple[size]
): The input shape. - reduce_dim (
Int
): The axis to perform the mean on. - output_shape (
StaticIntTuple[size]
): The output shape. - context (
MojoCallContextPtr
): The pointer to DeviceContext.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!