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

Function ParseCmdLine

tensorflow/core/profiler/internal/tfprof_utils.cc:115–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113} // namespace
114
115tensorflow::Status ParseCmdLine(const string& line, string* cmd,
116 tensorflow::tfprof::Options* opts) {
117 std::vector<string> pieces =
118 str_util::Split(line, ' ', str_util::SkipEmpty());
119
120 std::vector<string> cmds_str(kCmds, kCmds + sizeof(kCmds) / sizeof(*kCmds));
121 if (std::find(cmds_str.begin(), cmds_str.end(), pieces[0]) ==
122 cmds_str.end()) {
123 return tensorflow::Status(tensorflow::error::INVALID_ARGUMENT,
124 "First string must be a valid command.");
125 }
126 *cmd = pieces[0];
127
128 for (int i = 1; i < pieces.size(); ++i) {
129 if (pieces[i] == string(tensorflow::tfprof::kOptions[0])) {
130 if (pieces.size() <= i + 1 ||
131 !strings::safe_strto32(pieces[i + 1], &opts->max_depth)) {
132 return ReturnError(pieces, i);
133 }
134 ++i;
135 } else if (pieces[i] == tensorflow::tfprof::kOptions[1]) {
136 if (pieces.size() <= i + 1 ||
137 !strings::safe_strto64(pieces[i + 1], &opts->min_bytes)) {
138 return ReturnError(pieces, i);
139 }
140 ++i;
141 } else if (pieces[i] == tensorflow::tfprof::kOptions[2]) {
142 if (pieces.size() <= i + 1 ||
143 !strings::safe_strto64(pieces[i + 1], &opts->min_peak_bytes)) {
144 return ReturnError(pieces, i);
145 }
146 ++i;
147 } else if (pieces[i] == tensorflow::tfprof::kOptions[3]) {
148 if (pieces.size() <= i + 1 ||
149 !strings::safe_strto64(pieces[i + 1], &opts->min_residual_bytes)) {
150 return ReturnError(pieces, i);
151 }
152 ++i;
153 } else if (pieces[i] == tensorflow::tfprof::kOptions[4]) {
154 if (pieces.size() <= i + 1 ||
155 !strings::safe_strto64(pieces[i + 1], &opts->min_output_bytes)) {
156 return ReturnError(pieces, i);
157 }
158 ++i;
159 } else if (pieces[i] == tensorflow::tfprof::kOptions[5]) {
160 if (pieces.size() <= i + 1 ||
161 !strings::safe_strto64(pieces[i + 1], &opts->min_micros)) {
162 return ReturnError(pieces, i);
163 }
164 ++i;
165 } else if (pieces[i] == tensorflow::tfprof::kOptions[6]) {
166 if (pieces.size() <= i + 1 ||
167 !strings::safe_strto64(pieces[i + 1],
168 &opts->min_accelerator_micros)) {
169 return ReturnError(pieces, i);
170 }
171 ++i;
172 } else if (pieces[i] == tensorflow::tfprof::kOptions[7]) {

Callers 1

RunFunction · 0.85

Calls 14

SkipEmptyClass · 0.85
ReturnErrorFunction · 0.85
safe_strto64Function · 0.85
StripQuoteFunction · 0.85
StringToBoolFunction · 0.85
ParseOutputFunction · 0.85
SplitFunction · 0.50
StatusClass · 0.50
safe_strto32Function · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected