Skip to content
fn

maximum_op

→TensorImplPtr
int maximum_op(const int & a, const int & b)

Python wrappers

Public Python APIs implemented by this engine symbol.

Compute the elementwise maximum y=max⁡(a,b)y = \max(a, b) with broadcasting and autograd support.

Parameters

aTensorImplPtr
First operand.
bTensorImplPtr
Second operand. Broadcast-compatible with a.

Returns

TensorImplPtr

Tensor of shape broadcast(a.shape, b.shape) holding the elementwise maximum.

Notes

At ties (ai=bia_i = b_i) each operand receives half the gradient. When grad-tracking is on, registers a MaximumBackward node which saves both inputs.

Examples

>>> auto y = maximum_op(a, b);  // y[i] = max(a[i], b[i]) with broadcasting