[Refactor][Meta-schedule] Remove meta-schedule as_string mechanism in favor of default representation#19709
Conversation
fe04ec3 to
bcf403c
Compare
There was a problem hiding this comment.
Code Review
This pull request removes the AsString and __str__ methods across several Meta Schedule components (such as CostModel, FeatureExtractor, MeasureCallback, Mutator, Postproc, and ScheduleRule) in both C++ and Python, along with their associated tests and utility functions. The review feedback points out a copy-paste typo in the docstring of CostModel::PyCostModel that incorrectly refers to a "feature extractor" instead of a "cost model".
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| * \param f_predict The packed function of `Predict`. | ||
| * \param f_as_string The packed function of `AsString`. | ||
| * \return The feature extractor created. | ||
| * \return The cost model created. |
There was a problem hiding this comment.
There is a copy-paste typo in the docstring for CostModel::PyCostModel. It refers to a "feature extractor" instead of a "cost model". Please update it to refer to "cost model". Note that the first line of this docstring (which is outside the diff hunk) also contains "Create a feature extractor..." and should be updated to "Create a cost model..." as well.
* \return The cost model created.… favor of default representation (apache#19709) Python-side meta-schedule classes (`PyCostModel`, `PyFeatureExtractor`, `PyMeasureCallback`, `PyScheduleRule`, `PyMutator`, `PyPostproc`) carried an `f_as_string` callback whose only purpose was to produce a repr-style string (`s_tir.meta_schedule.<SubclassName>(0x...)`) for `str(...)`. This mechanism stopped working after apache#19461 migrated `ReprPrinter` to the tvm-ffi `__ffi_repr__` mechanism and intentionally removed the per-type `set_dispatch<Py*Node>` hooks that called back into `f_as_string`, which broke three `*_as_string` tests: - `test_meta_schedule_cost_model.py::test_meta_schedule_cost_model_as_string` - `test_meta_schedule_feature_extractor.py::test_meta_schedule_feature_extractor_as_string` - `test_meta_schedule_measure_callback.py::test_meta_schedule_measure_callback_as_string` Rather than restoring the old behavior, this PR removes the mechanism entirely: the string it produced is just a repr, and tvm-ffi reflection already provides an auto-generated default repr for every object. Keeping a dedicated Python → FFI → C++ callback chain alive only to reproduce that is not worth the complexity. (cherry picked from commit 219f1d8)
… favor of default representation (apache#19709) Python-side meta-schedule classes (`PyCostModel`, `PyFeatureExtractor`, `PyMeasureCallback`, `PyScheduleRule`, `PyMutator`, `PyPostproc`) carried an `f_as_string` callback whose only purpose was to produce a repr-style string (`s_tir.meta_schedule.<SubclassName>(0x...)`) for `str(...)`. This mechanism stopped working after apache#19461 migrated `ReprPrinter` to the tvm-ffi `__ffi_repr__` mechanism and intentionally removed the per-type `set_dispatch<Py*Node>` hooks that called back into `f_as_string`, which broke three `*_as_string` tests: - `test_meta_schedule_cost_model.py::test_meta_schedule_cost_model_as_string` - `test_meta_schedule_feature_extractor.py::test_meta_schedule_feature_extractor_as_string` - `test_meta_schedule_measure_callback.py::test_meta_schedule_measure_callback_as_string` Rather than restoring the old behavior, this PR removes the mechanism entirely: the string it produced is just a repr, and tvm-ffi reflection already provides an auto-generated default repr for every object. Keeping a dedicated Python → FFI → C++ callback chain alive only to reproduce that is not worth the complexity. (cherry picked from commit 219f1d8)
Python-side meta-schedule classes (
PyCostModel,PyFeatureExtractor,PyMeasureCallback,PyScheduleRule,PyMutator,PyPostproc) carried anf_as_stringcallback whose only purpose was to produce a repr-style string (s_tir.meta_schedule.<SubclassName>(0x...)) forstr(...).This mechanism stopped working after #19461 migrated
ReprPrinterto the tvm-ffi__ffi_repr__mechanism and intentionally removed the per-typeset_dispatch<Py*Node>hooks that called back intof_as_string, which broke three*_as_stringtests:test_meta_schedule_cost_model.py::test_meta_schedule_cost_model_as_stringtest_meta_schedule_feature_extractor.py::test_meta_schedule_feature_extractor_as_stringtest_meta_schedule_measure_callback.py::test_meta_schedule_measure_callback_as_stringRather than restoring the old behavior, this PR removes the mechanism entirely: the string it produced is just a repr, and tvm-ffi reflection already provides an auto-generated default repr for every object. Keeping a dedicated Python → FFI → C++ callback chain alive only to reproduce that is not worth the complexity.