Implementing kernel
C++ engine symbols that back this Python API.Element-wise division with broadcasting and dtype promotion, rounded as asked.
Computes input / other element-wise. With rounding_mode=None (true division) integer operands are promoted to a floating-point dtype, and division by zero produces +/-inf or NaN according to IEEE 754. rounding_mode="trunc" rounds the quotient toward zero and "floor" toward negative infinity (lucid.floor_divide); both keep an integer dtype for integer operands.
Parameters
Returns
TensorElement-wise result with shape broadcast(input.shape, other.shape) and
dtype determined by the usual type-promotion rules.
Raises
RuntimeErrorrounding_mode, on the CPU. Metal
gives -1 there without a device sync.NotImplementedErrorrounding_mode.lucid._C.engine.InvalidArgumentrounding_mode.Notes
Mathematical definition:
for None, "trunc" and "floor". "floor" is the exact floor of the real quotient; "trunc" truncates the rounded float quotient, so 1.0 / 0.1 truncates to 10 while it floors to 9, as in the reference. An integer quotient is exact in both modes.
Autograd: , ; a rounded quotient has a zero gradient.
Examples
>>> import lucid
>>> a = lucid.tensor([1.0, 2.0, 3.0])
>>> b = lucid.tensor([4.0, 5.0, 6.0])
>>> lucid.div(a, b)
Tensor([...])
>>> lucid.div(lucid.tensor([7, -7]), 2, rounding_mode="trunc")
Tensor([...])
>>> lucid.div(lucid.tensor([7, -7]), 2, rounding_mode="floor")
Tensor([...])