Registers a unary op that accepts extra keyword arguments beyond the mandatory "a" tensor operand.
Variadic in the extra-argument pack so that arbitrary
py::arg-style descriptors with default values can be
forwarded unchanged. Typical use cases are activation functions
with hyperparameters (leaky_relu(slope=0.01),
elu(alpha=1.0)). The callable template parameter Fn is
intentionally unconstrained so that both plain function pointers
and lambdas wrapping the C++ op can be passed.
See Also
bind_unary — without extra kwargs.
Parameters
mpy::module_&Target pybind11 module.
fnFnCallable implementing the op. Function pointer or lambda; the argument arity must match
"a" plus the forwarded extra descriptors.extra_argsPyArgs&&...Zero or more pybind11 argument descriptors (
py::arg("name") = default) appended after the implicit py::arg("a").Examples
Binding leaky ReLU with a slope hyperparameter: bind_unary_extra<LeakyReluBackward>(m, &leaky_relu_op,
py::arg("slope") = 0.01);