mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 19:27:05 -04:00
Model::read bounded each tensor but nothing else, so a tiny hostile .tflite could make Model::run abort on a huge CONV_2D patch allocation, or keep it busy for minutes. Read now works out from the static shapes, with checked arithmetic, what one run takes and refuses a model over a fixed budget: kernel side (32), one operator's working space (2^22 floats), multiply-adds (2^33), values written (2^30), floats alive at once (2^29) and constant values decoded or laid out at load (2^27). The shapes run() computes itself now have to match the declared ones (PAD, CONCATENATION, MAX_POOL_2D channels), and a zero dimension no longer lets the others grow without bound. Reported by KazW, with the suggested load-time budget. Co-Authored-By: Claude Opus 5.5 <[email protected]>