Glow: [InstrGen] Add capability to query operand name

Created on 7 Apr 2020  路  4Comments  路  Source: pytorch/glow

Modify InstrGen in order to have the capability to query the name of a positional operand:

  • For example instr.getOperandName(2) would retrieve Filter for a convolution instruction.

The method should be accessible from the base class for Instruction (when iterating through instructions we should be capable to call the method without upcasting the objects). This would be useful for debugging/printing procedures.

Most helpful comment

Hi,

one comment on this:

For example node.getOutputName(0) would retrieve Result for a convolution node.

IIUC you can get the output name of a GLOW node using:

node.getOutputName(idx) Look at this code snippet https://github.com/pytorch/glow/blob/00c4b150b657ca0de288ba14bec25531d111ffb8/tools/Debugger/NetworkComparator.cpp#L166:

void IntermediateLayerComparator::hookSingleNodeInPlace(
    Node &node, std::list<SaveNode *> &saveNodes,
    std::list<Placeholder *> &hookPlaceholders) {
  std::string layerName = node.getName();
  for (unsigned i = 0; i < node.getNumResults(); ++i) {
    std::string saveName = node.getOutputName(i);
    saveName += "_" + layerName + "_hook";
    SaveNode *save =
        node.getParent()->createSave(saveName, node.getNthResult(i));
    saveNodes.emplace_back(save);
    hookPlaceholders.emplace_back(save->getPlaceholder());
  }
}

All 4 comments

@opti-mix Would you be interested in doing this? I`m not sure what is the proper way to do it in terms of memory/run-time overhead, whether to modify the definition of the InstructionOperand type to include a string, etc.

Hi,

one comment on this:

For example node.getOutputName(0) would retrieve Result for a convolution node.

IIUC you can get the output name of a GLOW node using:

node.getOutputName(idx) Look at this code snippet https://github.com/pytorch/glow/blob/00c4b150b657ca0de288ba14bec25531d111ffb8/tools/Debugger/NetworkComparator.cpp#L166:

void IntermediateLayerComparator::hookSingleNodeInPlace(
    Node &node, std::list<SaveNode *> &saveNodes,
    std::list<Placeholder *> &hookPlaceholders) {
  std::string layerName = node.getName();
  for (unsigned i = 0; i < node.getNumResults(); ++i) {
    std::string saveName = node.getOutputName(i);
    saveName += "_" + layerName + "_hook";
    SaveNode *save =
        node.getParent()->createSave(saveName, node.getNthResult(i));
    saveNodes.emplace_back(save);
    hookPlaceholders.emplace_back(save->getPlaceholder());
  }
}

@SameerAsal You made a very good point! Thanks! And BTW, for Nodes we also have getInputName(idx).

But it seems we don't have the same kind of APIs for instructions yet, i.e. there is no getOperandName(idx).

Ok thanks for the info! I`ll update the description to reflect this only for the Instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

georgeokelly picture georgeokelly  路  4Comments

alannnna picture alannnna  路  3Comments

opti-mix picture opti-mix  路  4Comments

pjaaskel picture pjaaskel  路  4Comments

s-peryt picture s-peryt  路  3Comments