| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This example demonstrates a fused elementwise operation followed by normalization. This pattern combines elementwise tensor arithmetic with a normalization operation in a single kernel, which is particularly useful for implementing custom normalization layers or fused activation-normalization blocks.
The operation performs an elementwise computation followed by a normalization operation.
Elementwise Stage: An elementwise operation is applied to one or more input tensors. $C_{temp} = f(A, B, \dots)$ Where f is a user-defined elementwise function that operates on corresponding elements of the input tensors.
Normalization Stage: The result is then normalized. The normalization can be performed along specified dimensions.
The key optimization is that the intermediate tensor C_temp is never written to global memory. The elementwise computation feeds directly into the normalization calculation.
The implementation combines elementwise computation with an online normalization algorithm.
Grid Scheduling: The normalization groups are distributed among thread blocks. Each block handles one or more normalization groups.
Fused Two-Pass Algorithm:
This approach ensures that the elementwise computation is performed only once, and the results are immediately consumed by the normalization process without requiring additional memory bandwidth.
Ensure the Composable Kernel library is built and installed.
cd /path/to/composable_kernel/build
make -j installcd /path/to/composable_kernel/example/45_elementwise_normalization
mkdir build && cd build
cmake \
-DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
-DCMAKE_PREFIX_PATH="/opt/rocm;${CK_INSTALL_PATH}" \
..
make -j# Run the example with default settings
./elementwise_normalization_xdl
# Run with verification, data initialization, and timing
./elementwise_normalization_xdl 1 2 1This fused operation is valuable for implementing custom normalization layers and optimizing activation-normalization sequences.
| Back | FazBrowse Home | New Git URL |