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

Function DoListCommand

tensorflow/compiler/xla/tools/interactive_graphviz.cc:219–248  ·  view source on GitHub ↗

List all instructions matching a pattern.

Source from the content-addressed store, hash-verified

217
218// List all instructions matching a pattern.
219void DoListCommand(const HloModule& module, const std::vector<string>& tokens) {
220 string pattern = "";
221 string type = "name";
222 if (tokens.size() == 2) {
223 pattern = tokens[1];
224 } else if (tokens.size() == 3) {
225 type = tokens[1];
226 pattern = tokens[2];
227 } else {
228 std::cout << "Illegal list query syntax. Use "
229 << R"("list [name|op_name|op_type] pattern".)" << std::endl;
230 return;
231 }
232
233 std::cout << "Query results:" << std::endl;
234 for (const auto& computation : module.computations()) {
235 for (const auto& instr : computation->instructions()) {
236 if ((type == "name" && instr->name().find(pattern) != string::npos) ||
237 (type == "op_name" &&
238 instr->metadata().op_name().find(pattern) != string::npos) ||
239 (type == "op_type" &&
240 instr->metadata().op_type().find(pattern) != string::npos)) {
241 std::cout << " " << instr->name();
242 std::cout << ", op_name '" << instr->metadata().op_name() << "'";
243 std::cout << ", op_type '" << instr->metadata().op_type() << "'";
244 std::cout << std::endl;
245 }
246 }
247 }
248}
249
250// Print info about an instruction or computation.
251void DoInfoCommand(const HloModule& module, const std::vector<string>& tokens) {

Callers 1

InteractiveDumpGraphsFunction · 0.85

Calls 8

computationsMethod · 0.80
instructionsMethod · 0.80
metadataMethod · 0.80
nameMethod · 0.65
sizeMethod · 0.45
findMethod · 0.45
op_nameMethod · 0.45
op_typeMethod · 0.45

Tested by

no test coverage detected