1-parameter-classifier / rtl /sum_folded.v
CharlesCNorton
Image-level person classification on EUPE-ViT-B features with a single free parameter
f5498f9
Raw
History Blame Contribute Delete
1.86 kB
// Additive 1-parameter person classifier, threshold baked in.
// Generated by rtl_gen.py; do not edit by hand.
//
// Inputs are the 40 Stage 0 classifier dims as signed INT8, post-LayerNorm and
// post-max-pool. Output is one bit. Combinational, no multipliers, no memory.
module person_classifier_sum_folded (
input signed [7:0] f00, f01, f02, f03, f04, f05, f06, f07, f08, f09,
input signed [7:0] f10, f11, f12, f13, f14, f15, f16, f17, f18, f19,
input signed [7:0] f20, f21, f22, f23, f24, f25, f26, f27, f28, f29,
input signed [7:0] f30, f31, f32, f33, f34, f35, f36, f37, f38, f39,
output person_present
);
// Stage 0 threshold 25.2845 at the x8 scale used for the per-dim ones.
localparam signed [15:0] FINAL_T = 16'sd202;
wire signed [15:0] pos_sum =
{{8{f00[7]}}, f00} + {{8{f01[7]}}, f01} + {{8{f02[7]}}, f02} + {{8{f03[7]}}, f03} +
{{8{f04[7]}}, f04} + {{8{f05[7]}}, f05} + {{8{f06[7]}}, f06} + {{8{f07[7]}}, f07} +
{{8{f08[7]}}, f08} + {{8{f09[7]}}, f09} + {{8{f10[7]}}, f10} + {{8{f11[7]}}, f11} +
{{8{f12[7]}}, f12} + {{8{f13[7]}}, f13} + {{8{f14[7]}}, f14} + {{8{f15[7]}}, f15} +
{{8{f16[7]}}, f16} + {{8{f17[7]}}, f17} + {{8{f18[7]}}, f18} + {{8{f19[7]}}, f19};
wire signed [15:0] neg_sum =
{{8{f20[7]}}, f20} + {{8{f21[7]}}, f21} + {{8{f22[7]}}, f22} + {{8{f23[7]}}, f23} +
{{8{f24[7]}}, f24} + {{8{f25[7]}}, f25} + {{8{f26[7]}}, f26} + {{8{f27[7]}}, f27} +
{{8{f28[7]}}, f28} + {{8{f29[7]}}, f29} + {{8{f30[7]}}, f30} + {{8{f31[7]}}, f31} +
{{8{f32[7]}}, f32} + {{8{f33[7]}}, f33} + {{8{f34[7]}}, f34} + {{8{f35[7]}}, f35} +
{{8{f36[7]}}, f36} + {{8{f37[7]}}, f37} + {{8{f38[7]}}, f38} + {{8{f39[7]}}, f39};
wire signed [15:0] score = pos_sum - neg_sum;
assign person_present = score > FINAL_T;
endmodule