guberti opened a new pull request, #12521:
URL: https://github.com/apache/tvm/pull/12521

   Currently, AutoTVM's `ApplyHistoryBest` class does not support loading 
tuning logs from memory. This is a pet peeve of mine, as it requires you to 
work with a `tempfile` whenever writing autotuning tests. This is also just 
strange, as the rest of AutoTVM has support for text buffers (e.g. 
`tvm.autotvm.callback.log_to_file` supports passing in a text buffer, letting 
us write to but not read from them).
   
   Additionally, `ApplyHistoryBest` handles input arguments very unintuitively. 
Before this PR, it allowed users to pass string filepaths, a list of string 
filepaths, or an `Iterable` (such as a list) of input and result tuples. 
However, it did not support taking in `StringIO` objects as mentioned above, 
nor `pathlib.Path` objects, nor combinations of a filepath and an `Iterable` of 
tuples.
   
   In a perfect world, we would change `ApplyHistoryBest` to take as input a 
path-like object, file-like object, or an `Iterable` of input and result tuples 
(similar to what `ApplyGraphBest` takes as an argument). However, this would 
break the existing functionality to take as input a list of filepaths.
   
   To be backwards compatible, while fixing this issue, this pull request 
defines a new type:
   
   ```python
   Records = Union[
       Union[str, bytes, Path],  # Path-like objects
       TextIOBase,  # File-like objects
       Iterable[Tuple[MeasureInput, MeasureResult]],
   ]
   ```
   It then rewrites `ApplyHistoryBest.load` so it takes the following arguments:
   ```python
   def load(self, records: Union[Records, Iterable[Records]]):
   ```
   
   This PR also adds unit tests for this new functionality, and fixes a 
relevant bug in `tests/micro/common/test_autotune.py` in which a `StringIO` 
object was passed to `apply_history_best`, causing it to appear to pass but not 
actually read any data.


-- 
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]

Reply via email to