Skip to content
fn

sub_op

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

Python wrappers

Public Python APIs implemented by this engine symbol.

Public entry point — element-wise subtraction with autograd support.

Math

y=a−by = a - b

See Also

add_op, mul_op, div_op

Parameters

a, bconst TensorImplPtr&
Operands of any rank. Shapes must be NumPy-broadcast-compatible.

Returns

TensorImplPtr

Output tensor of shape broadcast_shapes(a.shape, b.shape) and promoted dtype. Participates in autograd via SubBackward.

Raises

LucidError
If a and b have incompatible shapes under NumPy broadcasting rules, or if their devices differ.

Examples

>>> auto c = sub_op(a, b);    // c = a - b