Aiden Grossman 085587e1a9 Reland "[MLGO] Remove Python <3.8 from unsupported config (#106132)"
This reverts commit c3776c11c26e5c0e27b772e6694e6c76f73ac9e8.

This relands commit a959d70eb5b6d47c0b32eb34fc409e50c01d722d.

This was originally causing bot failures on Python version 3.8.
This relanding fixes that by adjusting the relevant type annotations
that are not supported in earlier versions.
2024-08-26 18:45:34 -07:00

29 lines
740 B
Python

import log_reader
import interactive_host
import sys
from typing import Sequence
def main(args):
# this advisor just picks the first legal register to evict, which is
# identifiable by the "mask" feature
class Advisor:
to_return = False
def advice(self, tensor_values: Sequence[log_reader.TensorValue]):
for tv in tensor_values:
if tv.spec().name != "mask":
continue
for i, v in enumerate(tv):
if v == 1:
return i
# i.e. invalid:
return -1
a = Advisor()
interactive_host.run_interactive(args[0], a.advice, args[1:])
if __name__ == "__main__":
main(sys.argv[1:])