mvanhorn opened a new pull request, #20013:
URL: https://github.com/apache/tvm/pull/20013
## Summary
In `src/relax/transform/lift_transform_params.cc`, at the point where
`num_runtime_params` is read from the `kNumInput` attribute (the `if (auto opt
= func->attrs.GetAttr<int64_t>(attr::kNumInput))` block near line 411-416),
validate that the value is within `[0, func->params.size()]` and raise a clear
`TVM_FFI_ICHECK`/`LOG(FATAL)` with a descriptive message (e.g. "num_input (N)
exceeds the number of function parameters (M)") before it is stored into
`info_.num_runtime_params`.
## Why this matters
Applying the `PartitionTransformParams` pass (reached via
`relax.transform.LiftTransformParams()`) to a Relax module segfaults instead of
raising a diagnosable error. In the reporter's repro the `main` function is
annotated `R.func_attr({"num_input": 3})` but has only one parameter. In
`lift_transform_params.cc`, `LocalCollectInfo::num_runtime_params` is taken
directly from the `kNumInput` attribute (lines 411-416) with no validation
against `func->params.size()`.
## Testing
- Happy path: a module with a correct `num_input` annotation still
partitions/lifts its transform params unchanged (covered by existing tests,
confirm no regression).
- Edge: `num_input == params.size()` (all runtime params, zero compile-time
params) still succeeds without error.
- Error path: the reported case (`num_input` greater than the number of
parameters) raises a clear `TVMError` via `pytest.raises`, asserting the
message mentions `num_input`, and no longer segfaults.
Fixes #17460
AI was used for assistance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]