Skip to content
fn

cube_root_op

→TensorImplPtr
int cube_root_op(const int & a)

Element-wise cube root — returns a3\sqrt[3]{a} with a fully wired autograd node.

Defined for all real inputs (positive, zero, and negative); the negative branch is the real cube root, not the complex principal value.

Math

\frac{\partial y_i}{\partial x_i} = \frac{1}{3 y_i^{2}}$$ **Shape** Output shape equals input shape (elementwise). **See Also** `CubeRootBackward`.

Parameters

aTensorImplPtr
Input tensor (promoted to FP32 by the op schema).

Returns

TensorImplPtr

Output tensor with the same shape as a; gradient is g/(3y2)g / (3 y^{2}).

Notes

CPU implementation uses Accelerate's vvcbrtf; GPU uses MLX's power op with exponent 1/31/3. The gradient is singular at zero — avoid backpropagating through inputs that touch the origin.

Examples

``cube_root_op(-8.0) == -2.0``  (real cube root of a negative number).
``cube_root_op(27.0) == 3.0``.