--- layout: stdlib-reference --- # attribute [ForwardDerivative] ## Description [ForwardDerivative(fwdFn)] attribute can be used to provide a forward-mode derivative implementation. Invoking fwd_diff(decoratedFn) will place a call to fwdFn instead of synthesizing a derivative implementation. The same behavior holds if decoratedFn is used in a differentiable context. ## Signature
[ForwardDerivative(function)]## Parameters #### function ## Remarks - The signature of fwdFn must match the expected signature of fwd_diff(decoratedFn). - See the [reference](https://shader-slang.org/slang/user-guide/autodiff.html#fwd_difff--slang_function---slang_function) for fwd_diff for a full list of signature rules. - See the [user guide's section](https://shader-slang.org/slang/user-guide/autodiff.html#user-defined-derivative-functions) on custom derivatives for an introduction to this approach. - This attribute can be used on generic functions, member functions and accessors. - For generic functions, the generic signatures (parameters + constraints) of both functions must match exactly. - The decorated function will be considered forward-differentiable. There is no need for a [Differentiable] tag. If the [Differentiable] tag is present, and no custom backward derivative is specified with [BackwardDerivative], then the Slang will use auto-diff to generate the backward=mode derivative, but will use the provided derivative for forward-mode. Example: ```csharp [ForwardDerivative(foo_fwd)] T foo