brintos

brintos / llvm-project-archived public Read only

0
0
Text · 740 B · 1f62a5c Raw
29 lines · python
1import log_reader2import interactive_host3import sys4 5from typing import Sequence6 7def main(args):8    # this advisor just picks the first legal register to evict, which is9    # identifiable by the "mask" feature10    class Advisor:11        to_return = False12 13        def advice(self, tensor_values: Sequence[log_reader.TensorValue]):14            for tv in tensor_values:15                if tv.spec().name != "mask":16                    continue17                for i, v in enumerate(tv):18                    if v == 1:19                        return i20            # i.e. invalid:21            return -122 23    a = Advisor()24    interactive_host.run_interactive(args[0], a.advice, args[1:])25 26 27if __name__ == "__main__":28    main(sys.argv[1:])29