added a mapping from onnx outputs to cntk outputs into the graph's description

This commit is contained in:
Yang Chen 2019-07-18 00:39:00 -07:00
Родитель 99a272bf0c
Коммит f7f1e8dc98
1 изменённых файлов: 30 добавлений и 3 удалений

Просмотреть файл

@ -158,6 +158,32 @@ private:
return description;
}
//
// ONNX model description (of CNTK exported model) is in this format:
// <<<ONNXOutputName, CNTKNodeName>>> pair: <<<onnx_name_0, cntk_name_0>>> <<<onnx_name_0, cntk_name_1>>>
//
static std::string GetModelOutputNamePairDescription()
{
std::string description = "<<<ONNXOutputName, CNTKNodeName>>> pair: ";
bool first = true;
for (auto iter = outputUidNameMap.begin(); iter != outputUidNameMap.end(); ++iter)
{
std::string cntk_name = iter->second;
if (cntk_name == "")
continue;
auto uid_iter = uidNodeNameMap.find(iter->first);
if (uid_iter != uidNodeNameMap.end())
{
if (first)
description += " ";
else
first = false;
description += ("<<<" + uid_iter->second + ", " + cntk_name + ">>>");
}
}
return description;
}
//
// Generate unique name based on nodeName, opName and uid.
//
@ -1250,9 +1276,10 @@ void CNTKToONNXHelper::Copy(const FunctionPtr& src, onnxruntime::Graph* dst)
PostProcessGraph(dst);
//
// Save (Uid, ONNXNodeName) pair for all nodes to graph description.
// Save (Uid, ONNXNodeName) pair and (ONNXOutputName, CNTKNodeName) pair for all nodes to graph description.
//
dst->SetDescription(UniqueNodeNameStorage::GetUidNodeNamePairDescription());
dst->SetDescription(UniqueNodeNameStorage::GetUidNodeNamePairDescription() + "\n" +
UniqueNodeNameStorage::GetModelOutputNamePairDescription());
}
void CNTKToONNXHelper::HandleRootCombineOp(const FunctionPtr& src, onnxruntime::Graph* dst)
@ -9147,4 +9174,4 @@ std::unordered_map<std::string, std::string> CNTKToONNXHelper::UniqueNodeNameSto
std::unordered_set<std::string> CNTKToONNXHelper::UniqueNodeNameStorage::nodeNameSet;
std::unordered_map<Variable, Variable> CNTKToONNXHelper::UniqueNodeNameStorage::compositeOutputsMap;
std::unordered_map<Variable, Variable> CNTKToONNXHelper::compositeOutputsMap;
std::unordered_set<CNTKToONNXHelper::PostProcessFlag, CNTKToONNXHelper::PostProcessFlagHash> CNTKToONNXHelper::postProcessFlags;
std::unordered_set<CNTKToONNXHelper::PostProcessFlag, CNTKToONNXHelper::PostProcessFlagHash> CNTKToONNXHelper::postProcessFlags;