Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for elementwise tensor-tensor power with NumPy broadcasting.
Saves both inputs a and b (kSavesInputs = true inherited from
BinaryKernel) because both are needed in the backward formulas.
The gradient w.r.t. a is finite for any real ; the gradient w.r.t.
b is undefined when because is not real — in that
regime the returned gradient is non-finite and should be masked by the
caller.
Math
Shape
Inputs a, b follow NumPy broadcasting rules; the output y takes
the broadcast shape. Both backward branches are sum-reduced back to the
original input shapes by sum_to_shape in the apply trampoline.
See Also
mul_op : Elementwise multiplication. log_op : Natural logarithm (used by the branch).
Attributes
schema_ v1OpSchema"pow", version 1, AmpPolicy::ForceFP32, integral_closed, deterministic. A floating power runs in FP32 under autocast; an integer or bool power stays in its own dtype.Notes
For tensor-scalar power (constant exponent) prefer the scalar variant in
ScalarParam.h — it skips saving the exponent tensor and avoids the
log(a) * a^b branch entirely. See BinaryKernel for the
broadcasting / save-tensor / reduce-to-shape machinery.
Static methods
1Methods
2Compute the gradients for both inputs given the output gradient.
grad_formula_impl
int grad_formula_impl(const int & g, const int & a_ptr, const int & b_ptr)Graph-mode gradient for create_graph=True. dA = where(b == 0, 0, b * a^(b-1)) * g; dB = where(a == 0 && b >= 0, 0, log(a) * a^b) * g.