add the option dumpFileName to the NDLNetworkBuilder block so that before validation happens the network structure information can be saved to the file specified by this option. This will help to debug the NDL related issues.
This commit is contained in:
Родитель
909e8adfb0
Коммит
2c29a69661
|
@ -118,9 +118,10 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
}
|
||||
|
||||
//dump all nodes in the network to file
|
||||
void DumpAllNodesToFile(const bool printValues, const std::wstring outputFile)
|
||||
void DumpAllNodesToFile(const bool printValues, const std::wstring outputFile, const bool validateBeforeDump = true)
|
||||
{
|
||||
ValidateNetwork(); //some internal values in the nodes are computed during validation
|
||||
if (validateBeforeDump)
|
||||
ValidateNetwork(); //some internal values in the nodes are computed during validation
|
||||
|
||||
File fstream(outputFile, FileOptions::fileOptionsText | FileOptions::fileOptionsWrite);
|
||||
|
||||
|
|
|
@ -45,10 +45,12 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
IExecutionEngine<ElemType>* executionEngine,
|
||||
const std::wstring& networkConfig,
|
||||
const std::string& configParams,
|
||||
const std::wstring& dumpFileName,
|
||||
DEVICEID_TYPE deviceId=AUTOPLACEMATRIX)
|
||||
{
|
||||
m_executionEngine=executionEngine;
|
||||
m_networkConfig=networkConfig;
|
||||
m_dumpFileName = dumpFileName;
|
||||
m_initialConfig=configParams;
|
||||
m_deviceId=deviceId;
|
||||
m_net=&(executionEngine->GetComputationNetwork());
|
||||
|
@ -69,6 +71,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
{
|
||||
ConfigParameters newConfig;
|
||||
ConfigValue networkConfig = config("networkDescription","");
|
||||
ConfigValue dumpFileName = config("dumpFileName", "");
|
||||
DEVICEID_TYPE deviceId = DeviceFromConfig(config);
|
||||
unsigned long randomSeedOffset = config("randomSeedOffset","0");
|
||||
auto executionEngine = new SynchronousExecutionEngine<ElemType>(deviceId, randomSeedOffset);
|
||||
|
@ -142,7 +145,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
}
|
||||
}
|
||||
|
||||
Init(executionEngine, networkConfig, newConfig, deviceId);
|
||||
Init(executionEngine, networkConfig, newConfig, dumpFileName, deviceId);
|
||||
}
|
||||
|
||||
virtual ~NDLBuilder()
|
||||
|
@ -196,7 +199,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
m_script.FileParse(fileContents);
|
||||
|
||||
NDLUtil<ElemType> ndlUtil(m_net);
|
||||
ndlUtil.ProcessNDLScript(&m_script, ndlPassAll, nullptr, true);
|
||||
ndlUtil.ProcessNDLScript(&m_script, ndlPassAll, nullptr, true, m_dumpFileName);
|
||||
}
|
||||
|
||||
// SetFromConfig - Set the NDL script from a configuration string value
|
||||
|
@ -222,6 +225,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
ComputationNetwork<ElemType>* m_net;
|
||||
IExecutionEngine<ElemType>* m_executionEngine;
|
||||
std::wstring m_networkConfig;
|
||||
std::wstring m_dumpFileName;
|
||||
std::string m_initialConfig;
|
||||
|
||||
DEVICEID_TYPE m_deviceId;
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
// skipThrough - [in/out] for iterative processing, a pointer to an array of NDLNode*, one for each pass
|
||||
// the pointer will be updated to last node processed for that pass, can be NULL if all node processing is desired
|
||||
// fullValidate - validate as a complete network? (false if this might be a snippet of a full network)
|
||||
void ProcessNDLScript(NDLScript<ElemType>* script, NDLPass ndlPassUntil=ndlPassAll, NDLNode<ElemType>** skipThrough=nullptr, bool fullValidate = false)
|
||||
void ProcessNDLScript(NDLScript<ElemType>* script, NDLPass ndlPassUntil = ndlPassAll, NDLNode<ElemType>** skipThrough = nullptr, bool fullValidate = false, const std::wstring& dumpFileName = L"")
|
||||
{
|
||||
// if we don't have a script yet, don't bother
|
||||
if (script == nullptr)
|
||||
|
@ -104,7 +104,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
for (NDLPass ndlPass=ndlPassInitial;ndlPass <= ndlPassUntil;++ndlPass)
|
||||
{
|
||||
NDLNode<ElemType>* skipThroughNode = skipThrough?*skipThrough:nullptr;
|
||||
lastNode = ProcessPassNDLScript(script, ndlPass, skipThroughNode, fullValidate);
|
||||
lastNode = ProcessPassNDLScript(script, ndlPass, skipThroughNode, fullValidate, dumpFileName);
|
||||
if (skipThrough)
|
||||
{
|
||||
*skipThrough = lastNode;
|
||||
|
@ -119,13 +119,15 @@ namespace Microsoft { namespace MSR { namespace CNTK {
|
|||
// skipThrough - for iterative processing, skip through this node in the script (used for in-line MEL processing)
|
||||
// fullValidate - validate as a complete network? (false if this might be a snippet of a full network)
|
||||
// returns: last NDL node processed
|
||||
NDLNode<ElemType>* ProcessPassNDLScript(NDLScript<ElemType>* script, NDLPass ndlPass, NDLNode<ElemType>* skipThrough=nullptr, bool fullValidate = false)
|
||||
NDLNode<ElemType>* ProcessPassNDLScript(NDLScript<ElemType>* script, NDLPass ndlPass, NDLNode<ElemType>* skipThrough = nullptr, bool fullValidate = false, const std::wstring& dumpFileName = L"")
|
||||
{
|
||||
if (ndlPass == ndlPassFinal)
|
||||
{
|
||||
// make sure to clear the caches so we pick up the new nodes
|
||||
m_net->ClearCaches();
|
||||
// validate the network
|
||||
if (dumpFileName != L"")
|
||||
m_net->DumpAllNodesToFile(false, dumpFileName, false);
|
||||
m_net->ValidateNetwork(!fullValidate);
|
||||
}
|
||||
SynchronousNodeEvaluator<ElemType> ndlEvaluator(*m_net);
|
||||
|
|
Загрузка…
Ссылка в новой задаче