contrib-op-shape-inference-memory-safety
Installation
SKILL.md
Contrib-Op Shape-Inference Output-Index Safety
Reusable method for finding and fixing the bug class where an operator's
TypeAndShapeInference function guards an output write with getNumOutputs() > N but then
writes an output index greater than N. For a node that declares fewer outputs, the
written index is past the end of the inference context's output vector.
Scope: schema-level shape inference in
onnxruntime/core/graph/contrib_ops/*.ccandshape_inference_functions.cc. This runs once duringGraph::Resolve(model-load time), EP-agnostic - there is no per-EP (CPU/CUDA/ROCm) kernel duplicate of this code to chase. Op kernels allocate outputs via the bounds-safeOpKernelContext::Output(index)and are a separate concern.