Implementation:Alibaba MNN WinogradGenerateGLSL
| Property | Value |
|---|---|
| Page Type | Implementation |
| Repository | Alibaba MNN |
| Source File | backupcode/winogradGenerateGLSL.cpp (251 lines)
|
| Language | C++ |
| Domains | GPU_Computing, Convolution, Code_Generation |
| Date | 2026-02-10 |
Overview
⚠️ DEPRECATED: This tool resides in the backupcode/ directory and has been superseded by pre-generated static Vulkan GLSL shaders in source/backend/vulkan/image/execution/glsl/. See Alibaba_MNN_Warning_Deprecated_Winograd_Codegen for details.
WinogradGenerateGLSL is a command-line code generation tool that produces Vulkan GLSL compute shaders for Winograd convolution transforms. It serves the same algorithmic purpose as the OpenCL variant (Alibaba_MNN_WinogradGenerateCL) but targets the Vulkan/OpenGL compute pipeline by emitting .comp compute shader files.
The tool computes the Winograd transform matrices for a given F(m,r) configuration and encodes them as GLSL constants within compute shader source code. The generated shaders implement the source transform (input tile to Winograd domain) and destination transform (Winograd domain back to spatial output), enabling GPU-accelerated Winograd convolution on Vulkan-capable devices.
GLSL compute shaders differ from OpenCL kernels in their memory model, descriptor set bindings, and workgroup dispatch semantics, so the code generation logic accounts for these Vulkan-specific requirements.
Code Reference
Primary Entry Point
| Function | Location | Description |
|---|---|---|
main(int argc, const char* argv[]) |
backupcode/winogradGenerateGLSL.cpp:L87-251 |
Parses CLI arguments, invokes WinogradGenerater to compute transform matrices, and writes GLSL compute shader source to output files.
|
Function Signature
// backupcode/winogradGenerateGLSL.cpp:L87
int main(int argc, const char* argv[])
Key Includes
The tool shares the same mathematical foundation as the OpenCL variant, relying on WingoradGenerater for matrix computation:
#include <MNN/MNNDefine.h>
#include "math/Matrix.hpp"
#include "math/WingoradGenerater.hpp"
I/O Contract
Inputs
| Parameter | Type | Description |
|---|---|---|
unit |
int (CLI arg 1) | The output tile size m in the Winograd F(m, r) formulation. |
kernelSize |
int (CLI arg 2) | The convolution kernel size r. |
interp |
float (CLI arg 3) | Interpolation factor for transform point selection. |
Outputs
| Output | Format | Description |
|---|---|---|
| GLSL source transform shader | .comp file |
Vulkan compute shader performing B^T * d * B to transform input tiles into the Winograd domain.
|
| GLSL destination transform shader | .comp file |
Vulkan compute shader performing A^T * M * A to reconstruct spatial output tiles from Winograd domain results.
|
Usage Examples
Basic Invocation
Generate Winograd F(2,3) GLSL compute shaders:
./winogradGenerateGLSL 2 3 0.5
Generating F(4,3) Shaders
For larger tile configurations:
./winogradGenerateGLSL 4 3 1.0
This produces compute shaders for 6x6 input tiles with a 3x3 kernel, yielding 4x4 output tiles per transform.
Differences from OpenCL Variant
| Aspect | OpenCL (WinogradGenerateCL) |
GLSL (WinogradGenerateGLSL)
|
|---|---|---|
| Output format | .cl kernel source |
.comp compute shader source
|
| Target API | OpenCL | Vulkan / OpenGL Compute |
| Memory model | Global/local memory with __global qualifiers |
SSBO (Shader Storage Buffer Object) with descriptor set bindings |
| Dispatch model | NDRange work-items | Workgroup invocations via layout(local_size_x, ...)
|
Internal Workflow
- Parse command-line arguments for unit size, kernel size, and interpolation factor.
- Instantiate
WinogradGeneraterwith the specified parameters. - Compute the source transform matrix B and destination transform matrix A.
- Format matrix coefficients as GLSL float literals.
- Emit complete
.compshader files with Vulkan-compatible declarations, uniform bindings, and workgroup layout annotations.
Related Pages
- Principle: Alibaba_MNN_Winograd_Kernel_Codegen — Theoretical foundation of Winograd minimal filtering and automated GPU kernel code generation.
- Heuristic: Heuristic:Alibaba_MNN_Warning_Deprecated_Winograd_Codegen — Deprecation warning: this tool is superseded by pre-generated static shaders.
- Implementation: Alibaba_MNN_WinogradGenerateCL — Companion tool generating OpenCL kernels for the same Winograd transforms.