Limit AOT function expansion (#32662)
This pull request introduces a node and byte budget for Ahead-Of-Time
(AOT) function inlining in the ONNX Runtime graph partitioner, limiting
the expansion of functions during inlining to prevent excessive growth
in model size and complexity. It adds utility methods to count nodes
(including within subgraphs and functions), calculates expansion budgets
based on the original model size, and enforces these limits during
inlining. Additionally, a new unit test verifies the enforcement of
these limits.
**AOT Function Inlining Limits**
* Added counting utilities (`CountNodesIncludingSubgraphs`,
`CountModelNodes`, etc.) to recursively count nodes and protobuf size in
graphs, attributes, and functions to track potential expansion during
inlining.
* Introduced a configurable expansion ratio
(`kAotFunctionExpansionRatio`) and used it to compute node and byte
budgets for inlining, based on the original model's size.
* Updated `InlineFunctionsAOTImpl` to check and enforce node and byte
budgets before inlining each function, returning an error if the limits
would be exceeded.
[[1]](diffhunk://#diff-e2d3910ae7593ee7ba4fd74e53f738fa973ae2fc32c069f1088ba458b91f8d4bR1438-R1446)
[[2]](diffhunk://#diff-e2d3910ae7593ee7ba4fd74e53f738fa973ae2fc32c069f1088ba458b91f8d4bL1305-R1385)
[[3]](diffhunk://#diff-e2d3910ae7593ee7ba4fd74e53f738fa973ae2fc32c069f1088ba458b91f8d4bL1755-R1855)
**Testing**
* Added a new test (`AotInliningLimitsFunctionExpansion`) in
`function_test.cc` to verify that the inlining limits are enforced and
that exceeding them produces the expected error.