The LRN primitive performs a forward or backward local response normalization operation defined by the following formulas (the variable names follow the standard Naming Conventions):
LRN across channels:
\[ \dst(n, c, h, w) = \left\{k + \frac{\alpha}{n_{l}} \sum\limits_{i=-(n_{l}-1)/2}^{(n_{l}+1)/2-1} (\src(n, c+i, h, w))^2 \right\}^{-\beta} \cdot \src(n, c, h, w), \]
LRN within channel:
\[ \dst(n, c, h, w) = \left\{k + \frac{\alpha}{n_{l}} \sum\limits_{i=-(n_{l}-1)/2}^{(n_{l}+1)/2-1} \sum\limits_{j=-(n_{l}-1)/2}^{(n_{l}+1)/2-1} (\src(n, c, h+i, w+j))^2 \right\}^{-\beta} \cdot \src(n, c, h, w), \]
where \(n_{l}\) is the local_size. Formulas are provided for 2D spatial data case.
The backward propagation computes \(\)\diffsrc\f$(n, c, h, w) \(, based on \) \(\diffdst\)(n, c, h, w) \( and \) \(\src\)(n, c, h, w) \(. @section autotoc_md210 Execution Arguments When executed, the inputs and outputs should be mapped to an execution argument index as specified by the following table. <table class="markdownTable"> <tr class="markdownTableHead"> <th class="markdownTableHeadNone"> Primitive input/output \ilinebr </th> <th class="markdownTableHeadNone"> Execution argument index \ilinebr </th> </tr> <tr class="markdownTableRowOdd"> <td class="markdownTableBodyNone"> \)\src\f$
DNNL_ARG_SRC
\(\dst\)
DNNL_ARG_DST
workspace
DNNL_ARG_WORKSPACE
\(\diffsrc\)
DNNL_ARG_DIFF_SRC
\(\diffdst\)
DNNL_ARG_DIFF_DST
The LRN primitive supports the following combinations of data types:
| Propagation | Source / Destination |
|---|---|
| forward / backward | f32, bf16 |
| forward | f16 |
Like most other primitives, the LRN primitive expects the following tensors:
| Spatial | Source / Destination |
|---|---|
| 0D | \(N \times C\) |
| 1D | \(N \times C \times W\) |
| 2D | \(N \times C \times H \times W\) |
| 3D | \(N \times C \times D \times H \times W\) |
The LRN primitive is optimized for the following memory formats:
| Spatial | Logical tensor | Implementations optimized for memory formats |
|---|---|---|
| 2D | NCHW | dnnl_nchw (dnnl_abcd), dnnl_nhwc (dnnl_acdb), optimized^ |
Here optimized^ means the format that comes out of any preceding compute-intensive primitive.
The LRN primitive doesn't support any post-ops or attributes.
| Engine | Name | Comments |
|---|---|---|
| CPU/GPU | Local Response Normalization Primitive Example | This C++ API demonstrates how to create and execute a Local response normalization primitive in forward training propagation mode. |