MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ReadOpListFromFile

Function ReadOpListFromFile

tensorflow/python/framework/python_op_gen_main.cc:38–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace {
37
38Status 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:

Callers 1

ParseOpListCommandLineFunction · 0.85

Calls 8

DefaultFunction · 0.85
NewRandomAccessFileMethod · 0.45
getMethod · 0.45
ReadLineMethod · 0.45
okMethod · 0.45
GetResultMethod · 0.45
OneMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected