Skip to content

Support GlobalAveragePool#270

Open
npow wants to merge 1 commit into
Lagrange-Labs:masterfrom
npow:feature/avgpool-support
Open

Support GlobalAveragePool#270
npow wants to merge 1 commit into
Lagrange-Labs:masterfrom
npow:feature/avgpool-support

Conversation

@npow

@npow npow commented May 25, 2026

Copy link
Copy Markdown

Most modern classifiers (ResNet, EfficientNet, ViT) end in a global average pool, which the parser currently rejects.

GlobalAvgPool2D in layers/pooling.rs alongside MaxPool, with a sumcheck proof. PoolingProof becomes an enum (MaxPool, GlobalAvgPool) to keep the existing prover/verifier dispatch the same shape.

tract lowers ONNX GlobalAveragePool to Reduce<Sum> followed by a Mul normalizer, so the parser consumes both nodes and returns the Mul's id.

Also flipped a mem::replace to mem::take in prover.rs while I was in there.

Add GlobalAvgPool2D struct to pooling.rs with forward pass (op) and
ZK proof (prove_globalavgpool / verify_globalavgpool) using sumcheck.
Add PoolKind enum to PoolingCtx; refactor PoolingProof into enum
with MaxPool and GlobalAvgPool variants.
Update layers/mod.rs to handle the new PoolingProof enum.
Register 'Reduce<Sum>' in the ONNX parser (load_globalavgpool) so
tract-expanded GlobalAveragePool ops are parsed correctly; update
parse_node to prefer longest-matching key (GlobalAveragePool > Pool)
and fall back to matching by op type name.
Add tiny_avgpool.onnx test fixture and parser unit test.

All 146 lib tests pass (5 pre-existing GPT-2 model file failures unchanged).
Also fixes pre-existing clippy lint: mem::replace -> mem::take in prover.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant