LLVM 20.0.0git
|
Functions | |
def | send (io.BufferedWriter f, Union[int, float] value, log_reader.TensorSpec spec) |
def | run_interactive (str temp_rootname, Callable[[List[log_reader.TensorValue]], Union[int, float]] make_response, List[str] process_and_args) |
Utility for testing InteractiveModelRunner. Use it from pass-specific tests by providing a main .py which calls this library's `run_interactive` with an appropriate callback to provide advice. From .ll tests, just call the above-mentioned main as a prefix to the opt/llc invocation (with the appropriate flags enabling the interactive mode) Examples: test/Transforms/Inline/ML/interactive-mode.ll test/CodeGen/MLRegAlloc/interactive-mode.ll
def interactive_host.run_interactive | ( | str | temp_rootname, |
Callable[[List[log_reader.TensorValue]], Union[int, float]] | make_response, | ||
List[str] | process_and_args | ||
) |
Host the compiler. Args: temp_rootname: the base file name from which to construct the 2 pipes for communicating with the compiler. make_response: a function that, given the current tensor values, provides a response. process_and_args: the full commandline for the compiler. It it assumed it contains a flag poiting to `temp_rootname` so that the InteractiveModeRunner would attempt communication on the same pair as this function opens. This function sets up the communication with the compiler - via 2 files named `temp_rootname`.in and `temp_rootname`.out - prints out the received features, and sends back to the compiler an advice (which it gets from `make_response`). It's used for testing, and also to showcase how to set up communication in an interactive ML ("gym") environment.
Definition at line 35 of file interactive_host.py.
References log_reader.pretty_print_tensor_value(), print(), log_reader.read_header(), log_reader.read_one_observation(), and send().
def interactive_host.send | ( | io.BufferedWriter | f, |
Union[int, float] | value, | ||
log_reader.TensorSpec | spec | ||
) |
Send the `value` - currently just a scalar - formatted as per `spec`.
Definition at line 23 of file interactive_host.py.
Referenced by run_interactive().