Fix type reflection when input is an array-like - #8234
Conversation
This adds a new `infer_output_type` method for mapping an input to its corresponding output type. This new method is: - Simpler than the old one in `input_utils.py` - Maps better to how the new ingest `check_array` function treats inputs - Properly handles array-like inputs, rather than returning `None`
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR refactors cuML's input/output type inference by introducing a centralized ChangesArray type inference refactor
🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/merge |
Our type reflection routines no longer match the implementation now that we support array-like (e.g. list) inputs to cuml methods. The routines in
cuml.internals.validationtreat these as if they were numpy arrays (with respect to howmem_type=Noneclassifies them).Due to this, inference on array-like inputs would fail, since
determine_array_typewouldn't support array-like inputs, causing errors in our reflection machinery after the method had already successfully run.This:
infer_output_typefunction for inferring a correspondingoutput_typefrom a given input array-like. This new method is much simpler than the previous function that did this, and more closely matches how our new input validation routines treat input types. It's also in the same file as all the other reflection machinery, keeping the code closer together.infer_output_typeeverywheredetermine_array_typeused to be used. This fixed several bugs intest_sklearn_compatibility.determine_array_typeand related dead code ininput_utils.py