Mojo function
max
max[axis: Int](inp: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment], out: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment])
Computes maximum reduction along specified axis.
Reduces the input tensor by taking maximum elements along the specified axis and stores the result in the output tensor.
Constraints:
All tensors must have statically known shapes.
out.rank
must equal inp.rank - 1
.
Non-reduction dimensions must match between inp
and out
.
Currently only supports rank-2 inputs.
Parameters:
- axis (
Int
): The axis to take maximum along.
Args:
- inp (
LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]
): The input tensor to reduce. - out (
LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]
): The output tensor to store maximum results.
max[axis: Int](inp: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]) -> LayoutTensor[dtype, _reduce_res_row_major_shape(axis, layout), MutableAnyOrigin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth]
Computes maximum reduction along specified axis, returning a new tensor.
Reduces the input tensor by taking maximum elements along the specified axis and returns a new tensor with the results.
Constraints:
All tensors must have statically known shapes.
Result will have rank equal to inp.rank
- 1.
Non-reduction dimensions in the result match the input.
Currently only supports rank-2 inputs.
Parameters:
- axis (
Int
): The axis to take maximum along.
Args:
- inp (
LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]
): The input tensor to reduce.
Returns:
A new tensor containing the maximum values along the specified axis.
max[dtype: DType, layout: Layout](x: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment], y: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]) -> LayoutTensor[dtype, layout, MutableAnyOrigin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]
Computes element-wise maximum of two tensors.
Returns a new tensor containing the element-wise maximum between the input tensors.
Constraints:
Input tensors must have statically known shapes and matching layouts.
Parameters:
- dtype (
DType
): The data type of the input tensors. - layout (
Layout
): The layout of the input tensors.
Args:
- x (
LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]
): First input tensor. - y (
LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_bitwidth=layout_bitwidth, masked=masked, alignment=alignment]
): Second input tensor.
Returns:
A new tensor containing the element-wise maximum.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!