Download rtl/src/fa_output_normalizer.sv from Snapkitty/flash-attention-rtl: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/Snapkitty/flash-attention-rtl/resolve/main/rtl/src/fa_output_normalizer.sv
- Command line
-
hf download hf://Snapkitty/flash-attention-rtl/rtl/src/fa_output_normalizer.sv
-
curl -L -o fa_output_normalizer.sv https://huggingface.co/Snapkitty/flash-attention-rtl/resolve/main/rtl/src/fa_output_normalizer.sv
759 Bytes
| // OUTPUT_NORMALIZER: out = (o * 16) / l, truncated toward zero. | |
| // o is the PV accumulator (sum p*v), l the softmax denominator (sum p). | |
| // The result has 8 fractional bits (V is Q4.4). | |
| module fa_output_normalizer ( | |
| input logic clk, | |
| input logic rst_n, | |
| input logic start, | |
| input logic signed [63:0] o, | |
| input logic signed [63:0] l, | |
| output logic done, // pulse; out valid until next start | |
| output logic signed [31:0] out | |
| ); | |
| logic signed [63:0] quot; | |
| fa_divider #(.W(64)) u_div ( | |
| .clk, .rst_n, | |
| .start, | |
| .num(o <<< 4), | |
| .den(l), | |
| .done, | |
| .quot | |
| ); | |
| assign out = quot[31:0]; | |
| endmodule : fa_output_normalizer | |