@@ -158,6 +158,32 @@ class CNTKToONNXHelper
158
158
return description;
159
159
}
160
160
161
+ //
162
+ // ONNX model description (of CNTK exported model) is in this format:
163
+ // <<<ONNXOutputName, CNTKNodeName>>> pair: <<<onnx_name_0, cntk_name_0>>> <<<onnx_name_0, cntk_name_1>>>
164
+ //
165
+ static std::string GetModelOutputNamePairDescription ()
166
+ {
167
+ std::string description = " <<<ONNXOutputName, CNTKNodeName>>> pair: " ;
168
+ bool first = true ;
169
+ for (auto iter = outputUidNameMap.begin (); iter != outputUidNameMap.end (); ++iter)
170
+ {
171
+ std::string cntk_name = iter->second ;
172
+ if (cntk_name == " " )
173
+ continue ;
174
+ auto uid_iter = uidNodeNameMap.find (iter->first );
175
+ if (uid_iter != uidNodeNameMap.end ())
176
+ {
177
+ if (first)
178
+ description += " " ;
179
+ else
180
+ first = false ;
181
+ description += (" <<<" + uid_iter->second + " , " + cntk_name + " >>>" );
182
+ }
183
+ }
184
+ return description;
185
+ }
186
+
161
187
//
162
188
// Generate unique name based on nodeName, opName and uid.
163
189
//
@@ -1250,9 +1276,10 @@ void CNTKToONNXHelper::Copy(const FunctionPtr& src, onnxruntime::Graph* dst)
1250
1276
PostProcessGraph (dst);
1251
1277
1252
1278
//
1253
- // Save (Uid, ONNXNodeName) pair for all nodes to graph description.
1279
+ // Save (Uid, ONNXNodeName) pair and (ONNXOutputName, CNTKNodeName) pair for all nodes to graph description.
1254
1280
//
1255
- dst->SetDescription (UniqueNodeNameStorage::GetUidNodeNamePairDescription ());
1281
+ dst->SetDescription (UniqueNodeNameStorage::GetUidNodeNamePairDescription () + " \n " +
1282
+ UniqueNodeNameStorage::GetModelOutputNamePairDescription ());
1256
1283
}
1257
1284
1258
1285
void CNTKToONNXHelper::HandleRootCombineOp (const FunctionPtr& src, onnxruntime::Graph* dst)
@@ -9147,4 +9174,4 @@ std::unordered_map<std::string, std::string> CNTKToONNXHelper::UniqueNodeNameSto
9147
9174
std::unordered_set<std::string> CNTKToONNXHelper::UniqueNodeNameStorage::nodeNameSet;
9148
9175
std::unordered_map<Variable, Variable> CNTKToONNXHelper::UniqueNodeNameStorage::compositeOutputsMap;
9149
9176
std::unordered_map<Variable, Variable> CNTKToONNXHelper::compositeOutputsMap;
9150
- std::unordered_set<CNTKToONNXHelper::PostProcessFlag, CNTKToONNXHelper::PostProcessFlagHash> CNTKToONNXHelper::postProcessFlags;
9177
+ std::unordered_set<CNTKToONNXHelper::PostProcessFlag, CNTKToONNXHelper::PostProcessFlagHash> CNTKToONNXHelper::postProcessFlags;
0 commit comments