| 36 | namespace { |
| 37 | |
| 38 | Status ReadOpListFromFile(const string& filename, |
| 39 | std::vector<string>* op_list) { |
| 40 | std::unique_ptr<RandomAccessFile> file; |
| 41 | TF_CHECK_OK(Env::Default()->NewRandomAccessFile(filename, &file)); |
| 42 | std::unique_ptr<io::InputBuffer> input_buffer( |
| 43 | new io::InputBuffer(file.get(), 256 << 10)); |
| 44 | string line_contents; |
| 45 | Status s = input_buffer->ReadLine(&line_contents); |
| 46 | while (s.ok()) { |
| 47 | // The parser assumes that the op name is the first string on each |
| 48 | // line with no preceding whitespace, and ignores lines that do |
| 49 | // not start with an op name as a comment. |
| 50 | strings::Scanner scanner{StringPiece(line_contents)}; |
| 51 | StringPiece op_name; |
| 52 | if (scanner.One(strings::Scanner::LETTER_DIGIT_DOT) |
| 53 | .Any(strings::Scanner::LETTER_DIGIT_DASH_DOT_SLASH_UNDERSCORE) |
| 54 | .GetResult(nullptr, &op_name)) { |
| 55 | op_list->emplace_back(op_name); |
| 56 | } |
| 57 | s = input_buffer->ReadLine(&line_contents); |
| 58 | } |
| 59 | if (!errors::IsOutOfRange(s)) return s; |
| 60 | return Status::OK(); |
| 61 | } |
| 62 | |
| 63 | // The argument parsing is deliberately simplistic to support our only |
| 64 | // known use cases: |
no test coverage detected